[PATCH] D92506: Remove memory allocation with string

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 5 11:44:31 PST 2020


hiraditya updated this revision to Diff 309744.
hiraditya added a comment.

remove consume


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92506/new/

https://reviews.llvm.org/D92506

Files:
  llvm/lib/Option/OptTable.cpp


Index: llvm/lib/Option/OptTable.cpp
===================================================================
--- llvm/lib/Option/OptTable.cpp
+++ llvm/lib/Option/OptTable.cpp
@@ -196,11 +196,13 @@
 
 // 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;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92506.309744.patch
Type: text/x-patch
Size: 717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201205/a06ab95f/attachment.bin>


More information about the llvm-commits mailing list