mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-11 02:07:09 -06:00
4.20
This commit is contained in:
committed by
Kornel Lesiński
parent
8c1b5c7b7e
commit
3c510ba80b
@@ -1,7 +1,5 @@
|
||||
// Common/DynamicBuffer.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __COMMON_DYNAMICBUFFER_H
|
||||
#define __COMMON_DYNAMICBUFFER_H
|
||||
|
||||
@@ -12,14 +10,14 @@ template <class T> class CDynamicBuffer: public CBuffer<T>
|
||||
void GrowLength(size_t size)
|
||||
{
|
||||
size_t delta;
|
||||
if (_capacity > 64)
|
||||
delta = _capacity / 4;
|
||||
else if (_capacity > 8)
|
||||
if (this->_capacity > 64)
|
||||
delta = this->_capacity / 4;
|
||||
else if (this->_capacity > 8)
|
||||
delta = 16;
|
||||
else
|
||||
delta = 4;
|
||||
delta = MyMax(delta, size);
|
||||
SetCapacity(_capacity + delta);
|
||||
SetCapacity(this->_capacity + delta);
|
||||
}
|
||||
public:
|
||||
CDynamicBuffer(): CBuffer<T>() {};
|
||||
@@ -27,18 +25,18 @@ public:
|
||||
CDynamicBuffer(size_t size): CBuffer<T>(size) {};
|
||||
CDynamicBuffer& operator=(const CDynamicBuffer &buffer)
|
||||
{
|
||||
Free();
|
||||
this->Free();
|
||||
if(buffer._capacity > 0)
|
||||
{
|
||||
SetCapacity(buffer._capacity);
|
||||
memmove(_items, buffer._items, buffer._capacity * sizeof(T));
|
||||
memmove(this->_items, buffer._items, buffer._capacity * sizeof(T));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
void EnsureCapacity(size_t capacity)
|
||||
{
|
||||
if (_capacity < capacity)
|
||||
GrowLength(capacity - _capacity);
|
||||
if (this->_capacity < capacity)
|
||||
GrowLength(capacity - this->_capacity);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user