diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/include/fxcrt/fx_basic.h | 18 | ||||
-rw-r--r-- | core/src/fxcrt/extension.h | 2 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_array.cpp | 26 |
3 files changed, 15 insertions, 31 deletions
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h index bdb1599491..af8dceb969 100644 --- a/core/include/fxcrt/fx_basic.h +++ b/core/include/fxcrt/fx_basic.h @@ -384,7 +384,7 @@ protected: ~CFX_BasicArray(); - FX_BOOL SetSize(int nNewSize, int nGrowBy); + FX_BOOL SetSize(int nNewSize); FX_BOOL Append(const CFX_BasicArray& src); @@ -405,8 +405,6 @@ protected: int m_nMaxSize; - int m_nGrowBy; - int m_nUnitSize; }; template<class TYPE> @@ -426,14 +424,14 @@ public: return m_nSize - 1; } - FX_BOOL SetSize(int nNewSize, int nGrowBy = -1) + FX_BOOL SetSize(int nNewSize) { - return CFX_BasicArray::SetSize(nNewSize, nGrowBy); + return CFX_BasicArray::SetSize(nNewSize); } void RemoveAll() { - SetSize(0, -1); + SetSize(0); } const TYPE GetAt(int nIndex) const @@ -477,7 +475,7 @@ public: return FALSE; } if (nIndex >= m_nSize) - if (!SetSize(nIndex + 1, -1)) { + if (!SetSize(nIndex + 1)) { return FALSE; } ((TYPE*)m_pData)[nIndex] = newElement; @@ -488,7 +486,7 @@ public: { if (m_nSize < m_nMaxSize) { m_nSize ++; - } else if (!SetSize(m_nSize + 1, -1)) { + } else if (!SetSize(m_nSize + 1)) { return FALSE; } ((TYPE*)m_pData)[m_nSize - 1] = newElement; @@ -652,7 +650,7 @@ public: return 0; } RemoveAll(); - SetSize(nCount, -1); + SetSize(nCount); ObjectClass* pStartObj = (ObjectClass*)m_pData; nSize = nStart + nCount; for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++) { @@ -689,7 +687,7 @@ public: for (int i = 0; i < m_nSize; i ++) { ((ObjectClass*)GetDataPtr(i))->~ObjectClass(); } - CFX_BasicArray::SetSize(0, -1); + CFX_BasicArray::SetSize(0); } }; typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray; diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index 8d9597bfd1..671b4736ef 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -372,7 +372,7 @@ protected: } FX_INT32 iCount = m_Blocks.GetSize(); size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize; - m_Blocks.SetSize(m_Blocks.GetSize() + (FX_INT32)size, -1); + m_Blocks.SetSize(m_Blocks.GetSize() + (FX_INT32)size); IFX_Allocator* pAllocator = m_Blocks.m_pAllocator; while (size --) { FX_LPBYTE pBlock = FX_Allocator_Alloc(pAllocator, FX_BYTE, m_nGrowSize); diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp index 3de3d99ac1..4ce29aa91f 100644 --- a/core/src/fxcrt/fx_basic_array.cpp +++ b/core/src/fxcrt/fx_basic_array.cpp @@ -12,7 +12,6 @@ CFX_BasicArray::CFX_BasicArray(int unit_size, IFX_Allocator* pAllocator) , m_pData(NULL) , m_nSize(0) , m_nMaxSize(0) - , m_nGrowBy(0) { if (unit_size < 0 || unit_size > (1 << 28)) { m_nUnitSize = 4; @@ -24,7 +23,7 @@ CFX_BasicArray::~CFX_BasicArray() { FX_Allocator_Free(m_pAllocator, m_pData); } -FX_BOOL CFX_BasicArray::SetSize(int nNewSize, int nGrowBy) +FX_BOOL CFX_BasicArray::SetSize(int nNewSize) { if (nNewSize <= 0) { FX_Free(m_pData); @@ -33,8 +32,6 @@ FX_BOOL CFX_BasicArray::SetSize(int nNewSize, int nGrowBy) return 0 == nNewSize; } - m_nGrowBy = nGrowBy >= 0 ? nGrowBy : m_nGrowBy; - if (m_pData == NULL) { base::CheckedNumeric<int> totalSize = nNewSize; totalSize *= m_nUnitSize; @@ -55,18 +52,7 @@ FX_BOOL CFX_BasicArray::SetSize(int nNewSize, int nGrowBy) } m_nSize = nNewSize; } else { - int nGrowBy = m_nGrowBy; - if (nGrowBy == 0) { - nGrowBy = m_nSize / 8; - nGrowBy = (nGrowBy < 4) ? 4 : ((nGrowBy > 1024) ? 1024 : nGrowBy); - } - int nNewMax; - if (nNewSize < m_nMaxSize + nGrowBy) { - nNewMax = m_nMaxSize + nGrowBy; - } else { - nNewMax = nNewSize; - } - + int nNewMax = nNewSize < m_nMaxSize ? m_nMaxSize : nNewSize; base::CheckedNumeric<int> totalSize = nNewMax; totalSize *= m_nUnitSize; if (!totalSize.IsValid() || nNewMax < m_nSize) { @@ -88,7 +74,7 @@ FX_BOOL CFX_BasicArray::Append(const CFX_BasicArray& src) int nOldSize = m_nSize; base::CheckedNumeric<int> newSize = m_nSize; newSize += src.m_nSize; - if (m_nUnitSize != src.m_nUnitSize || !newSize.IsValid() || !SetSize(newSize.ValueOrDie(), -1)) { + if (m_nUnitSize != src.m_nUnitSize || !newSize.IsValid() || !SetSize(newSize.ValueOrDie())) { return FALSE; } @@ -97,7 +83,7 @@ FX_BOOL CFX_BasicArray::Append(const CFX_BasicArray& src) } FX_BOOL CFX_BasicArray::Copy(const CFX_BasicArray& src) { - if (!SetSize(src.m_nSize, -1)) { + if (!SetSize(src.m_nSize)) { return FALSE; } FXSYS_memcpy32(m_pData, src.m_pData, src.m_nSize * m_nUnitSize); @@ -109,12 +95,12 @@ FX_LPBYTE CFX_BasicArray::InsertSpaceAt(int nIndex, int nCount) return NULL; } if (nIndex >= m_nSize) { - if (!SetSize(nIndex + nCount, -1)) { + if (!SetSize(nIndex + nCount)) { return NULL; } } else { int nOldSize = m_nSize; - if (!SetSize(m_nSize + nCount, -1)) { + if (!SetSize(m_nSize + nCount)) { return NULL; } FXSYS_memmove32(m_pData + (nIndex + nCount)*m_nUnitSize, m_pData + nIndex * m_nUnitSize, |