1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Remove memory allocation with string

Differential Revision: https://reviews.llvm.org/D92506
This commit is contained in:
Aditya Kumar 2020-12-05 11:43:45 -08:00
parent 9ea76a985a
commit 1a3db3fca7

View File

@ -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;
}