[llvm-commits] [llvm] r67473 - /llvm/trunk/include/llvm/ADT/SmallVector.h
Chris Lattner
sabre at nondot.org
Sun Mar 22 12:22:55 PDT 2009
Author: lattner
Date: Sun Mar 22 14:22:53 2009
New Revision: 67473
URL: http://llvm.org/viewvc/llvm-project?rev=67473&view=rev
Log:
Fix PR3860 by correcting a predicate.
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=67473&r1=67472&r2=67473&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallVector.h Sun Mar 22 14:22:53 2009
@@ -293,10 +293,11 @@
// Uninvalidate the iterator.
I = begin()+InsertElt;
- // If we already have this many elements in the collection, append the
- // dest elements at the end, then copy over the appropriate elements. Since
- // we already reserved space, we know that this won't reallocate the vector.
- if (size() >= NumToInsert) {
+ // If there are more elements between the insertion point and the end of the
+ // range than there are being inserted, we can use a simple approach to
+ // insertion. Since we already reserved space, we know that this won't
+ // reallocate the vector.
+ if (size_t(end()-I) >= NumToInsert) {
T *OldEnd = End;
append(End-NumToInsert, End);
@@ -341,10 +342,11 @@
// Uninvalidate the iterator.
I = begin()+InsertElt;
- // If we already have this many elements in the collection, append the
- // dest elements at the end, then copy over the appropriate elements. Since
- // we already reserved space, we know that this won't reallocate the vector.
- if (size() >= NumToInsert) {
+ // If there are more elements between the insertion point and the end of the
+ // range than there are being inserted, we can use a simple approach to
+ // insertion. Since we already reserved space, we know that this won't
+ // reallocate the vector.
+ if (size_t(end()-I) >= NumToInsert) {
T *OldEnd = End;
append(End-NumToInsert, End);
More information about the llvm-commits
mailing list