[TableGen] Restructure a loop to make it exit early instead of skipping a portion...
authorCraig Topper <craig.topper@gmail.com>
Sat, 16 May 2015 05:42:03 +0000 (05:42 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 16 May 2015 05:42:03 +0000 (05:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237511 91177308-0d34-0410-b5e6-96231b3b80d8

lib/TableGen/Record.cpp

index 1b5a902dea689b035932327343f2254a9abcddf5..0ce7b6f5d98866d0c3d51febd6353d334b61b309 100644 (file)
@@ -1113,12 +1113,13 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
 
       std::string::size_type found;
       std::string::size_type idx = 0;
 
       std::string::size_type found;
       std::string::size_type idx = 0;
-      do {
+      while (true) {
         found = Val.find(LHSs->getValue(), idx);
         found = Val.find(LHSs->getValue(), idx);
-        if (found != std::string::npos)
-          Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
-        idx = found +  MHSs->getValue().size();
-      } while (found != std::string::npos);
+        if (found == std::string::npos)
+          break;
+        Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
+        idx = found + MHSs->getValue().size();
+      }
 
       return StringInit::get(Val);
     }
 
       return StringInit::get(Val);
     }