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 | b6ff0f3a4de2882abc83931d4a78bb1533353cbd (patch) | |
| tree | 26fb656addc6b1021d15f893bd2cf6df56f90e2f /llvm | |
| parent | 34cef4c1c82c8f03f174c1388c7c4c1827feeab7 (diff) | |
| download | llvm-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.h | 18 |
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); |
