MCPcopy Create free account
hub / github.com/catboost/catboost / ExpandSize

Method ExpandSize

util/generic/bitmap.h:260–277  ·  view source on GitHub ↗

Returns true if the resulting storage capacity is enough to fit the requested size

Source from the content-addressed store, hash-verified

258
259 // Returns true if the resulting storage capacity is enough to fit the requested size
260 Y_FORCE_INLINE bool ExpandSize(size_t size, bool keepData = true) {
261 if (size > Size) {
262 size = Max(size, Size * 2);
263 TArrayHolder<TChunk> newData(new TChunk[size]);
264 if (keepData) {
265 for (size_t i = 0; i < Size; ++i) {
266 newData[i] = Data[i];
267 }
268 for (size_t i = Size; i < size; ++i) {
269 newData[i] = 0;
270 }
271 }
272 DoSwap(ArrayData, newData);
273 Data = ArrayData.Get();
274 Size = size;
275 }
276 return true;
277 }
278
279 Y_FORCE_INLINE bool ExpandBitSize(size_t bitSize, bool keepData = true) {
280 return ExpandSize((bitSize + 8 * sizeof(TChunk) - 1) / (8 * sizeof(TChunk)), keepData);

Callers

nothing calls this directly

Calls 3

MaxFunction · 0.70
DoSwapFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected