[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 20:44:42 PDT 2017
ruiu created this revision.
Herald added a subscriber: emaste.
Pointed out by Yuka Takahashi.
https://reviews.llvm.org/D34192
Files:
lld/ELF/Driver.cpp
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/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.102473.patch
Type: text/x-patch
Size: 862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170614/88db9ff4/attachment.bin>
More information about the llvm-commits
mailing list