Replace std::copy with a back inserter with vector append where feasible

All of the cases were just appending from random access iterators to a
vector. Using insert/append can grow the vector to the perfect size
directly and moves the growing out of the loop. No intended functionalty
change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230845 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer
2015-02-28 10:11:12 +00:00
parent 12d1e53db8
commit 31fbd9f7b0
8 changed files with 15 additions and 21 deletions

View File

@ -312,8 +312,7 @@ static const Value *getNoopInput(const Value *V,
// previous aggregate. Combine the two paths to obtain the true address of
// our element.
ArrayRef<unsigned> ExtractLoc = EVI->getIndices();
std::copy(ExtractLoc.rbegin(), ExtractLoc.rend(),
std::back_inserter(ValLoc));
ValLoc.append(ExtractLoc.rbegin(), ExtractLoc.rend());
NoopInput = Op;
}
// Terminate if we couldn't find anything to look through.
@ -601,10 +600,8 @@ bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
// The manipulations performed when we're looking through an insertvalue or
// an extractvalue would happen at the front of the RetPath list, so since
// we have to copy it anyway it's more efficient to create a reversed copy.
using std::copy;
SmallVector<unsigned, 4> TmpRetPath, TmpCallPath;
copy(RetPath.rbegin(), RetPath.rend(), std::back_inserter(TmpRetPath));
copy(CallPath.rbegin(), CallPath.rend(), std::back_inserter(TmpCallPath));
SmallVector<unsigned, 4> TmpRetPath(RetPath.rbegin(), RetPath.rend());
SmallVector<unsigned, 4> TmpCallPath(CallPath.rbegin(), CallPath.rend());
// Finally, we can check whether the value produced by the tail call at this
// index is compatible with the value we return.