Deleted Added
full compact
SmallVector.cpp (208954) SmallVector.cpp (210299)
1//===- llvm/ADT/SmallVector.cpp - 'Normally small' vectors ----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 7 unchanged lines hidden (view full) ---

16
17/// grow_pod - This is an implementation of the grow() method which only works
18/// on POD-like datatypes and is out of line to reduce code duplication.
19void SmallVectorBase::grow_pod(size_t MinSizeInBytes, size_t TSize) {
20 size_t CurSizeBytes = size_in_bytes();
21 size_t NewCapacityInBytes = 2 * capacity_in_bytes();
22 if (NewCapacityInBytes < MinSizeInBytes)
23 NewCapacityInBytes = MinSizeInBytes;
1//===- llvm/ADT/SmallVector.cpp - 'Normally small' vectors ----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 7 unchanged lines hidden (view full) ---

16
17/// grow_pod - This is an implementation of the grow() method which only works
18/// on POD-like datatypes and is out of line to reduce code duplication.
19void SmallVectorBase::grow_pod(size_t MinSizeInBytes, size_t TSize) {
20 size_t CurSizeBytes = size_in_bytes();
21 size_t NewCapacityInBytes = 2 * capacity_in_bytes();
22 if (NewCapacityInBytes < MinSizeInBytes)
23 NewCapacityInBytes = MinSizeInBytes;
24 void *NewElts = operator new(NewCapacityInBytes);
25
26 // Copy the elements over. No need to run dtors on PODs.
27 memcpy(NewElts, this->BeginX, CurSizeBytes);
28
29 // If this wasn't grown from the inline copy, deallocate the old space.
30 if (!this->isSmall())
31 operator delete(this->BeginX);
32
24
25 void *NewElts;
26 if (this->isSmall()) {
27 NewElts = malloc(NewCapacityInBytes);
28
29 // Copy the elements over. No need to run dtors on PODs.
30 memcpy(NewElts, this->BeginX, CurSizeBytes);
31 } else {
32 // If this wasn't grown from the inline copy, grow the allocated space.
33 NewElts = realloc(this->BeginX, NewCapacityInBytes);
34 }
35
33 this->EndX = (char*)NewElts+CurSizeBytes;
34 this->BeginX = NewElts;
35 this->CapacityX = (char*)this->BeginX + NewCapacityInBytes;
36}
37
36 this->EndX = (char*)NewElts+CurSizeBytes;
37 this->BeginX = NewElts;
38 this->CapacityX = (char*)this->BeginX + NewCapacityInBytes;
39}
40