Skip to content

Commit c4e327a

Browse files
committed
Remove memory allocation with string
Differential Revision: https://reviews.llvm.org/D92506
1 parent 930b339 commit c4e327a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/lib/Option/OptTable.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,13 @@ static unsigned matchOption(const OptTable::Info *I, StringRef Str,
196196

197197
// Returns true if one of the Prefixes + In.Names matches Option
198198
static bool optionMatches(const OptTable::Info &In, StringRef Option) {
199-
if (In.Prefixes)
199+
if (In.Prefixes) {
200+
StringRef InName(In.Name);
200201
for (size_t I = 0; In.Prefixes[I]; I++)
201-
if (Option.endswith(In.Name))
202-
if (Option == std::string(In.Prefixes[I]) + In.Name)
202+
if (Option.endswith(InName))
203+
if (Option.slice(0, Option.size() - InName.size()) == In.Prefixes[I])
203204
return true;
205+
}
204206
return false;
205207
}
206208

0 commit comments

Comments
 (0)