#include "llvm/ADT/iterator.h"
#include "llvm/Support/type_traits.h"
#include <algorithm>
+#include <cassert>
#include <cstring>
#include <memory>
-#include <cassert>
#ifdef _MSC_VER
namespace std {
// 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);
// 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);