From a4b093e2d3f053d2de5a93793e9019c232a91e12 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 16 May 2015 05:42:03 +0000 Subject: [PATCH] [TableGen] Restructure a loop to make it exit early instead of skipping a portion of the body based on what will also be the terminating condition. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237511 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/TableGen/Record.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index 1b5a902dea6..0ce7b6f5d98 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -1113,12 +1113,13 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { std::string::size_type found; std::string::size_type idx = 0; - do { + while (true) { 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); } -- 2.34.1