diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-22 19:22:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-22 19:22:53 +0000 |
commit | dae2206390be0b1886cf0c1dba3edf079d28274f (patch) | |
tree | 880772370eded505007689dcd2949b45780e8922 /include/llvm/ADT | |
parent | 19527c6ef371c6a09743bf91d4bee36b32241b12 (diff) | |
download | external_llvm-dae2206390be0b1886cf0c1dba3edf079d28274f.zip external_llvm-dae2206390be0b1886cf0c1dba3edf079d28274f.tar.gz external_llvm-dae2206390be0b1886cf0c1dba3edf079d28274f.tar.bz2 |
Fix PR3860 by correcting a predicate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67473 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/SmallVector.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index da91a65e..445f991 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/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); |