aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-22 19:22:53 +0000
committerChris Lattner <sabre@nondot.org>2009-03-22 19:22:53 +0000
commitb6ff0f3a4de2882abc83931d4a78bb1533353cbd (patch)
tree26fb656addc6b1021d15f893bd2cf6df56f90e2f /llvm
parent34cef4c1c82c8f03f174c1388c7c4c1827feeab7 (diff)
downloadllvm-b6ff0f3a4de2882abc83931d4a78bb1533353cbd.zip
llvm-b6ff0f3a4de2882abc83931d4a78bb1533353cbd.tar.gz
llvm-b6ff0f3a4de2882abc83931d4a78bb1533353cbd.tar.bz2
Fix PR3860 by correcting a predicate.
llvm-svn: 67473
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/ADT/SmallVector.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index da91a65e..445f991 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -293,10 +293,11 @@ public:
// 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 @@ public:
// 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);