aboutsummaryrefslogtreecommitdiff
path: root/lib/TableGen/StringMatcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/TableGen/StringMatcher.cpp')
-rw-r--r--lib/TableGen/StringMatcher.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/TableGen/StringMatcher.cpp b/lib/TableGen/StringMatcher.cpp
index 0ce626d4b1..16681702d1 100644
--- a/lib/TableGen/StringMatcher.cpp
+++ b/lib/TableGen/StringMatcher.cpp
@@ -87,11 +87,11 @@ EmitStringMatcherForChar(const std::vector<const StringPair*> &Matches,
<< Matches[0]->first[CharNo] << "')\n";
OS << Indent << " break;\n";
} else {
- // Do the comparison with if (Str.substr(1, 3) != "foo").
+ // Do the comparison with if memcmp(Str.data()+1, "foo", 3).
// FIXME: Need to escape general strings.
- OS << Indent << "if (" << StrVariableName << ".substr(" << CharNo << ", "
- << NumChars << ") != \"";
- OS << Matches[0]->first.substr(CharNo, NumChars) << "\")\n";
+ OS << Indent << "if (memcmp(" << StrVariableName << ".data()+" << CharNo
+ << ", \"" << Matches[0]->first.substr(CharNo, NumChars) << "\", "
+ << NumChars << "))\n";
OS << Indent << " break;\n";
}