X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FADT%2FSmallVector.h;h=445f99190085106c7a2acece129332c49b549e57;hb=76d38384542e2f596e14eb8e80b8e1c6a2652fd1;hp=c981d5756b3af2aa8f882f32bd3d79e30fc87b29;hpb=38deef9ce58b33dba34515f23fb7dbde02164c77;p=oota-llvm.git diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index c981d5756b3..445f9919008 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -17,9 +17,9 @@ #include "llvm/ADT/iterator.h" #include "llvm/Support/type_traits.h" #include +#include #include #include -#include #ifdef _MSC_VER namespace std { @@ -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);