Author: Aditya Kumar Date: 2020-12-05T15:14:44-08:00 New Revision: c4e327a960d20e18f3a8116da51a5686c628d51b
URL: https://github.com/llvm/llvm-project/commit/c4e327a960d20e18f3a8116da51a5686c628d51b DIFF: https://github.com/llvm/llvm-project/commit/c4e327a960d20e18f3a8116da51a5686c628d51b.diff LOG: Remove memory allocation with string Differential Revision: https://reviews.llvm.org/D92506 Added: Modified: llvm/lib/Option/OptTable.cpp Removed: ################################################################################ diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp index 304c09fff9d2..9564b4433f0c 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; } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits