[lld] r305364 - Use StringRef::split instead of StringRef::find and StringRef::substr.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 13 21:02:40 PDT 2017
Author: ruiu
Date: Tue Jun 13 23:02:40 2017
New Revision: 305364
URL: http://llvm.org/viewvc/llvm-project?rev=305364&view=rev
Log:
Use StringRef::split instead of StringRef::find and StringRef::substr.
Summary: Pointed out by Yuka Takahashi.
Differential Revision: https://reviews.llvm.org/D34192
Modified:
lld/trunk/ELF/Driver.cpp
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=305364&r1=305363&r2=305364&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Jun 13 23:02:40 2017
@@ -306,13 +306,11 @@ static bool hasZOption(opt::InputArgList
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;
}
}
More information about the llvm-commits
mailing list