diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-02-17 15:29:18 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-02-17 15:29:18 +0000 |
commit | 6cd780ff2143656df213359b7a6df9a5a9237e17 (patch) | |
tree | b3689d2b8496e1cc569d85b5c59b0ac1d68beace /llvm/lib/Option | |
parent | 2ba8778157390981ba1e4a3b683aee09aa9f009f (diff) | |
download | bcm5719-llvm-6cd780ff2143656df213359b7a6df9a5a9237e17.tar.gz bcm5719-llvm-6cd780ff2143656df213359b7a6df9a5a9237e17.zip |
Prefer SmallVector::append/insert over push_back loops.
Same functionality, but hoists the vector growth out of the loop.
llvm-svn: 229500
Diffstat (limited to 'llvm/lib/Option')
-rw-r--r-- | llvm/lib/Option/Arg.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/Option/ArgList.cpp | 4 |
2 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/Option/Arg.cpp b/llvm/lib/Option/Arg.cpp index 4c8da58f536..af632d6922b 100644 --- a/llvm/lib/Option/Arg.cpp +++ b/llvm/lib/Option/Arg.cpp @@ -83,15 +83,13 @@ void Arg::renderAsInput(const ArgList &Args, ArgStringList &Output) const { return; } - for (unsigned i = 0, e = getNumValues(); i != e; ++i) - Output.push_back(getValue(i)); + Output.append(Values.begin(), Values.end()); } void Arg::render(const ArgList &Args, ArgStringList &Output) const { switch (getOption().getRenderStyle()) { case Option::RenderValuesStyle: - for (unsigned i = 0, e = getNumValues(); i != e; ++i) - Output.push_back(getValue(i)); + Output.append(Values.begin(), Values.end()); break; case Option::RenderCommaJoinedStyle: { @@ -109,14 +107,12 @@ void Arg::render(const ArgList &Args, ArgStringList &Output) const { case Option::RenderJoinedStyle: Output.push_back(Args.GetOrMakeJoinedArgString( getIndex(), getSpelling(), getValue(0))); - for (unsigned i = 1, e = getNumValues(); i != e; ++i) - Output.push_back(getValue(i)); + Output.append(Values.begin() + 1, Values.end()); break; case Option::RenderSeparateStyle: Output.push_back(Args.MakeArgString(getSpelling())); - for (unsigned i = 0, e = getNumValues(); i != e; ++i) - Output.push_back(getValue(i)); + Output.append(Values.begin(), Values.end()); break; } } diff --git a/llvm/lib/Option/ArgList.cpp b/llvm/lib/Option/ArgList.cpp index b1a916d5c44..85e956f1ead 100644 --- a/llvm/lib/Option/ArgList.cpp +++ b/llvm/lib/Option/ArgList.cpp @@ -253,8 +253,8 @@ void ArgList::AddAllArgValues(ArgStringList &Output, OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const { for (auto Arg : filtered(Id0, Id1, Id2)) { Arg->claim(); - for (unsigned i = 0, e = Arg->getNumValues(); i != e; ++i) - Output.push_back(Arg->getValue(i)); + const auto &Values = Arg->getValues(); + Output.append(Values.begin(), Values.end()); } } |