@@ -603,9 +603,7 @@ class SmallVectorImpl : public SmallVectorTemplateBase<T> {
603
603
void append (in_iter in_start, in_iter in_end) {
604
604
this ->assertSafeToAddRange (in_start, in_end);
605
605
size_type NumInputs = std::distance (in_start, in_end);
606
- if (NumInputs > this ->capacity () - this ->size ())
607
- this ->grow (this ->size ()+NumInputs);
608
-
606
+ this ->reserve (this ->size () + NumInputs);
609
607
this ->uninitialized_copy (in_start, in_end, this ->end ());
610
608
this ->set_size (this ->size () + NumInputs);
611
609
}
@@ -888,10 +886,8 @@ void SmallVectorImpl<T>::swap(SmallVectorImpl<T> &RHS) {
888
886
std::swap (this ->Capacity , RHS.Capacity );
889
887
return ;
890
888
}
891
- if (RHS.size () > this ->capacity ())
892
- this ->grow (RHS.size ());
893
- if (this ->size () > RHS.capacity ())
894
- RHS.grow (this ->size ());
889
+ this ->reserve (RHS.size ());
890
+ RHS.reserve (this ->size ());
895
891
896
892
// Swap the shared elements.
897
893
size_t NumShared = this ->size ();
@@ -946,8 +942,7 @@ SmallVectorImpl<T> &SmallVectorImpl<T>::
946
942
// FIXME: don't do this if they're efficiently moveable.
947
943
if (this ->capacity () < RHSSize) {
948
944
// Destroy current elements.
949
- this ->destroy_range (this ->begin (), this ->end ());
950
- this ->set_size (0 );
945
+ this ->clear ();
951
946
CurSize = 0 ;
952
947
this ->grow (RHSSize);
953
948
} else if (CurSize) {
@@ -1006,8 +1001,7 @@ SmallVectorImpl<T> &SmallVectorImpl<T>::operator=(SmallVectorImpl<T> &&RHS) {
1006
1001
// elements.
1007
1002
if (this ->capacity () < RHSSize) {
1008
1003
// Destroy current elements.
1009
- this ->destroy_range (this ->begin (), this ->end ());
1010
- this ->set_size (0 );
1004
+ this ->clear ();
1011
1005
CurSize = 0 ;
1012
1006
this ->grow (RHSSize);
1013
1007
} else if (CurSize) {
0 commit comments