[PATCH] D34192: Use StringRef::split instead of StringRef::find and StringRef::substr.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 21:03:25 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL305364: Use StringRef::split instead of StringRef::find and StringRef::substr. (authored by ruiu).

Changed prior to commit:
  https://reviews.llvm.org/D34192?vs=102473&id=102475#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34192

Files:
  lld/trunk/ELF/Driver.cpp


Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -306,13 +306,11 @@
 static uint64_t getZOptionValue(opt::InputArgList &Args, StringRef Key,
                                 uint64_t Default) {
   for (auto *Arg : Args.filtered(OPT_z)) {
-    StringRef Value = Arg->getValue();
-    size_t Pos = Value.find("=");
-    if (Pos != StringRef::npos && Key == Value.substr(0, Pos)) {
-      Value = Value.substr(Pos + 1);
+    std::pair<StringRef, StringRef> KV = StringRef(Arg->getValue()).split('=');
+    if (KV.first == Key) {
       uint64_t Result;
-      if (!to_integer(Value, Result))
-        error("invalid " + Key + ": " + Value);
+      if (!to_integer(KV.second, Result))
+        error("invalid " + Key + ": " + KV.second);
       return Result;
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34192.102475.patch
Type: text/x-patch
Size: 880 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170614/e7a59126/attachment.bin>


More information about the llvm-commits mailing list