[llvm-commits] [llvm] r159914 - /llvm/trunk/include/llvm/ADT/SmallVector.h
Benjamin Kramer
benny.kra at googlemail.com
Sun Jul 8 05:06:35 PDT 2012
Author: d0k
Date: Sun Jul 8 07:06:35 2012
New Revision: 159914
URL: http://llvm.org/viewvc/llvm-project?rev=159914&view=rev
Log:
SmallVector: Make use of move semantics to speed up moving objects in erase() and insert()
Modified:
llvm/trunk/include/llvm/ADT/SmallVector.h
Modified: llvm/trunk/include/llvm/ADT/SmallVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=159914&r1=159913&r2=159914&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallVector.h Sun Jul 8 07:06:35 2012
@@ -465,7 +465,7 @@
iterator erase(iterator I) {
iterator N = I;
// Shift all elts down one.
- std::copy(I+1, this->end(), I);
+ this->move(I+1, this->end(), I);
// Drop the last elt.
this->pop_back();
return(N);
@@ -474,7 +474,7 @@
iterator erase(iterator S, iterator E) {
iterator N = S;
// Shift all elts down.
- iterator I = std::copy(E, this->end(), S);
+ iterator I = this->move(E, this->end(), S);
// Drop the last elts.
this->destroy_range(I, this->end());
this->setEnd(I);
@@ -572,11 +572,11 @@
// Otherwise, we're inserting more elements than exist already, and we're
// not inserting at the end.
- // Copy over the elements that we're about to overwrite.
+ // Move over the elements that we're about to overwrite.
T *OldEnd = this->end();
this->setEnd(this->end() + NumToInsert);
size_t NumOverwritten = OldEnd-I;
- this->uninitialized_copy(I, OldEnd, this->end()-NumOverwritten);
+ this->uninitialized_move(I, OldEnd, this->end()-NumOverwritten);
// Replace the overwritten part.
std::fill_n(I, NumOverwritten, Elt);
@@ -622,11 +622,11 @@
// Otherwise, we're inserting more elements than exist already, and we're
// not inserting at the end.
- // Copy over the elements that we're about to overwrite.
+ // Move over the elements that we're about to overwrite.
T *OldEnd = this->end();
this->setEnd(this->end() + NumToInsert);
size_t NumOverwritten = OldEnd-I;
- this->uninitialized_copy(I, OldEnd, this->end()-NumOverwritten);
+ this->uninitialized_move(I, OldEnd, this->end()-NumOverwritten);
// Replace the overwritten part.
for (T *J = I; NumOverwritten > 0; --NumOverwritten) {
More information about the llvm-commits
mailing list