Skip to content

Commit

Permalink
Use StringRef::split instead of StringRef::find and StringRef::substr.
Browse files Browse the repository at this point in the history
Summary: Pointed out by Yuka Takahashi.

Differential Revision: https://reviews.llvm.org/D34192

llvm-svn: 305364
  • Loading branch information
rui314 committed Jun 14, 2017
1 parent b936a39 commit d3a4a3e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lld/ELF/Driver.cpp
Expand Up @@ -306,13 +306,11 @@ static bool hasZOption(opt::InputArgList &Args, StringRef Key) {
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;
}
}
Expand Down

0 comments on commit d3a4a3e

Please sign in to comment.