From 77fc4c146f0870ffb09c1afb823ccbe742c5e6ff Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 25 Dec 2021 23:30:44 +0100 Subject: Vendor import of llvm-project main llvmorg-14-init-13186-g0c553cc1af2e. --- llvm/lib/TableGen/StringMatcher.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'llvm/lib/TableGen/StringMatcher.cpp') diff --git a/llvm/lib/TableGen/StringMatcher.cpp b/llvm/lib/TableGen/StringMatcher.cpp index 7f30c7b60752..7474c5dfe885 100644 --- a/llvm/lib/TableGen/StringMatcher.cpp +++ b/llvm/lib/TableGen/StringMatcher.cpp @@ -32,8 +32,8 @@ FindFirstNonCommonLetter(const std::vectorfirst[i]; - for (unsigned str = 0, e = Matches.size(); str != e; ++str) - if (Matches[str]->first[i] != Letter) + for (const StringMatcher::StringPair *Match : Matches) + if (Match->first[i] != Letter) return i; } @@ -75,9 +75,8 @@ bool StringMatcher::EmitStringMatcherForChar( // Bucket the matches by the character we are comparing. std::map> MatchesByLetter; - for (unsigned i = 0, e = Matches.size(); i != e; ++i) - MatchesByLetter[Matches[i]->first[CharNo]].push_back(Matches[i]); - + for (const StringPair *Match : Matches) + MatchesByLetter[Match->first[CharNo]].push_back(Match); // If we have exactly one bucket to match, see how many characters are common // across the whole set and match all of them at once. @@ -135,8 +134,8 @@ void StringMatcher::Emit(unsigned Indent, bool IgnoreDuplicates) const { // First level categorization: group strings by length. std::map> MatchesByLength; - for (unsigned i = 0, e = Matches.size(); i != e; ++i) - MatchesByLength[Matches[i].first.size()].push_back(&Matches[i]); + for (const StringPair &Match : Matches) + MatchesByLength[Match.first.size()].push_back(&Match); // Output a switch statement on length and categorize the elements within each // bin. -- cgit v1.3