aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Option/OptTable.cpp
diff options
context:
space:
mode:
authorAditya Kumar <1894981+hiraditya@users.noreply.github.com>2020-12-05 11:43:45 -0800
committerAditya Kumar <1894981+hiraditya@users.noreply.github.com>2020-12-05 15:14:44 -0800
commitc4e327a960d20e18f3a8116da51a5686c628d51b (patch)
tree7534d911f5aad8e9a9745922443287e4786d2b20 /llvm/lib/Option/OptTable.cpp
parent930b3398c7e4b3b15a9f262a2856d11fb2071eb7 (diff)
downloadllvm-c4e327a960d20e18f3a8116da51a5686c628d51b.zip
llvm-c4e327a960d20e18f3a8116da51a5686c628d51b.tar.gz
llvm-c4e327a960d20e18f3a8116da51a5686c628d51b.tar.bz2
Remove memory allocation with string
Differential Revision: https://reviews.llvm.org/D92506
Diffstat (limited to 'llvm/lib/Option/OptTable.cpp')
-rw-r--r--llvm/lib/Option/OptTable.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp
index 304c09f..9564b44 100644
--- a/llvm/lib/Option/OptTable.cpp
+++ b/llvm/lib/Option/OptTable.cpp
@@ -196,11 +196,13 @@ static unsigned matchOption(const OptTable::Info *I, StringRef Str,
// Returns true if one of the Prefixes + In.Names matches Option
static bool optionMatches(const OptTable::Info &In, StringRef Option) {
- if (In.Prefixes)
+ if (In.Prefixes) {
+ StringRef InName(In.Name);
for (size_t I = 0; In.Prefixes[I]; I++)
- if (Option.endswith(In.Name))
- if (Option == std::string(In.Prefixes[I]) + In.Name)
+ if (Option.endswith(InName))
+ if (Option.slice(0, Option.size() - InName.size()) == In.Prefixes[I])
return true;
+ }
return false;
}