diff options
author | tsepez <tsepez@chromium.org> | 2016-04-06 15:56:31 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-06 15:56:31 -0700 |
commit | 6334af71040b6148e9001aad4bd134a6c6c14a8d (patch) | |
tree | 0edfe0ea9686b68e420dcc98a93e129a31fc02fe /core | |
parent | 7222ea6936cbcff886037e4d8d4018e13a7f720f (diff) | |
download | pdfium-6334af71040b6148e9001aad4bd134a6c6c14a8d.tar.xz |
Remove CFX_SegmentedArray.
Recent changes appear to have made this unused.
Review URL: https://codereview.chromium.org/1864813003
Diffstat (limited to 'core')
-rw-r--r-- | core/fxcrt/fx_basic_array.cpp | 206 | ||||
-rw-r--r-- | core/fxcrt/include/fx_basic.h | 65 |
2 files changed, 0 insertions, 271 deletions
diff --git a/core/fxcrt/fx_basic_array.cpp b/core/fxcrt/fx_basic_array.cpp index 74988f7747..eb6570d950 100644 --- a/core/fxcrt/fx_basic_array.cpp +++ b/core/fxcrt/fx_basic_array.cpp @@ -134,209 +134,3 @@ const void* CFX_BasicArray::GetDataPtr(int index) const { } return m_pData + index * m_nUnitSize; } -#ifdef PDF_ENABLE_XFA -CFX_BaseSegmentedArray::CFX_BaseSegmentedArray(int unit_size, - int segment_units, - int index_size) - : m_UnitSize(unit_size), - m_SegmentSize(segment_units), - m_IndexSize(index_size), - m_IndexDepth(0), - m_DataSize(0), - m_pIndex(NULL) {} -void CFX_BaseSegmentedArray::SetUnitSize(int unit_size, - int segment_units, - int index_size) { - ASSERT(m_DataSize == 0); - m_UnitSize = unit_size; - m_SegmentSize = segment_units; - m_IndexSize = index_size; -} -CFX_BaseSegmentedArray::~CFX_BaseSegmentedArray() { - RemoveAll(); -} -static void _ClearIndex(int level, int size, void** pIndex) { - if (level == 0) { - FX_Free(pIndex); - return; - } - for (int i = 0; i < size; ++i) { - if (pIndex[i]) - _ClearIndex(level - 1, size, (void**)pIndex[i]); - } - FX_Free(pIndex); -} -void CFX_BaseSegmentedArray::RemoveAll() { - if (!m_pIndex) { - return; - } - _ClearIndex(m_IndexDepth, m_IndexSize, (void**)m_pIndex); - m_pIndex = NULL; - m_IndexDepth = 0; - m_DataSize = 0; -} -void* CFX_BaseSegmentedArray::Add() { - if (m_DataSize % m_SegmentSize) { - return GetAt(m_DataSize++); - } - void* pSegment = FX_Alloc2D(uint8_t, m_UnitSize, m_SegmentSize); - if (!m_pIndex) { - m_pIndex = pSegment; - m_DataSize++; - return pSegment; - } - if (m_IndexDepth == 0) { - void** pIndex = FX_Alloc(void*, m_IndexSize); - pIndex[0] = m_pIndex; - pIndex[1] = pSegment; - m_pIndex = pIndex; - m_DataSize++; - m_IndexDepth++; - return pSegment; - } - int seg_index = m_DataSize / m_SegmentSize; - if (seg_index % m_IndexSize) { - void** pIndex = GetIndex(seg_index); - pIndex[seg_index % m_IndexSize] = pSegment; - m_DataSize++; - return pSegment; - } - int tree_size = 1; - int i; - for (i = 0; i < m_IndexDepth; i++) { - tree_size *= m_IndexSize; - } - if (m_DataSize == tree_size * m_SegmentSize) { - void** pIndex = FX_Alloc(void*, m_IndexSize); - pIndex[0] = m_pIndex; - m_pIndex = pIndex; - m_IndexDepth++; - } else { - tree_size /= m_IndexSize; - } - void** pSpot = (void**)m_pIndex; - for (i = 1; i < m_IndexDepth; i++) { - if (!pSpot[seg_index / tree_size]) { - pSpot[seg_index / tree_size] = FX_Alloc(void*, m_IndexSize); - } - pSpot = (void**)pSpot[seg_index / tree_size]; - seg_index = seg_index % tree_size; - tree_size /= m_IndexSize; - } - if (i < m_IndexDepth) { - FX_Free(pSegment); - RemoveAll(); - return NULL; - } - pSpot[seg_index % m_IndexSize] = pSegment; - m_DataSize++; - return pSegment; -} -void** CFX_BaseSegmentedArray::GetIndex(int seg_index) const { - ASSERT(m_IndexDepth != 0); - if (m_IndexDepth == 1) { - return (void**)m_pIndex; - } - if (m_IndexDepth == 2) { - return (void**)((void**)m_pIndex)[seg_index / m_IndexSize]; - } - int tree_size = 1; - int i; - for (i = 1; i < m_IndexDepth; i++) { - tree_size *= m_IndexSize; - } - void** pSpot = (void**)m_pIndex; - for (i = 1; i < m_IndexDepth; i++) { - pSpot = (void**)pSpot[seg_index / tree_size]; - seg_index = seg_index % tree_size; - tree_size /= m_IndexSize; - } - return pSpot; -} -void* CFX_BaseSegmentedArray::IterateSegment(const uint8_t* pSegment, - int count, - FX_BOOL (*callback)(void* param, - void* pData), - void* param) const { - for (int i = 0; i < count; i++) { - if (!callback(param, (void*)(pSegment + i * m_UnitSize))) { - return (void*)(pSegment + i * m_UnitSize); - } - } - return NULL; -} -void* CFX_BaseSegmentedArray::IterateIndex(int level, - int& start, - void** pIndex, - FX_BOOL (*callback)(void* param, - void* pData), - void* param) const { - if (level == 0) { - int count = m_DataSize - start; - if (count > m_SegmentSize) { - count = m_SegmentSize; - } - start += count; - return IterateSegment((const uint8_t*)pIndex, count, callback, param); - } - for (int i = 0; i < m_IndexSize; i++) { - if (!pIndex[i]) { - continue; - } - void* p = - IterateIndex(level - 1, start, (void**)pIndex[i], callback, param); - if (p) { - return p; - } - } - return NULL; -} -void* CFX_BaseSegmentedArray::Iterate(FX_BOOL (*callback)(void* param, - void* pData), - void* param) const { - if (!m_pIndex) { - return NULL; - } - int start = 0; - return IterateIndex(m_IndexDepth, start, (void**)m_pIndex, callback, param); -} -void* CFX_BaseSegmentedArray::GetAt(int index) const { - if (index < 0 || index >= m_DataSize) { - return NULL; - } - if (m_IndexDepth == 0) { - return (uint8_t*)m_pIndex + m_UnitSize * index; - } - int seg_index = index / m_SegmentSize; - return (uint8_t*)GetIndex(seg_index)[seg_index % m_IndexSize] + - (index % m_SegmentSize) * m_UnitSize; -} -void CFX_BaseSegmentedArray::Delete(int index, int count) { - if (index < 0 || count < 1 || index + count > m_DataSize) { - return; - } - int i; - for (i = index; i < m_DataSize - count; i++) { - uint8_t* pSrc = (uint8_t*)GetAt(i + count); - uint8_t* pDest = (uint8_t*)GetAt(i); - for (int j = 0; j < m_UnitSize; j++) { - pDest[j] = pSrc[j]; - } - } - int new_segs = (m_DataSize - count + m_SegmentSize - 1) / m_SegmentSize; - int old_segs = (m_DataSize + m_SegmentSize - 1) / m_SegmentSize; - if (new_segs < old_segs) { - if (m_IndexDepth) { - for (i = new_segs; i < old_segs; i++) { - void** pIndex = GetIndex(i); - FX_Free(pIndex[i % m_IndexSize]); - pIndex[i % m_IndexSize] = NULL; - } - } else { - FX_Free(m_pIndex); - m_pIndex = NULL; - } - } - m_DataSize -= count; -} -#endif // PDF_ENABLE_XFA diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h index 2ef11beb27..744b2dd10f 100644 --- a/core/fxcrt/include/fx_basic.h +++ b/core/fxcrt/include/fx_basic.h @@ -491,71 +491,6 @@ class CFX_ObjectArray : public CFX_BasicArray { }; typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray; typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray; -class CFX_BaseSegmentedArray { - public: - CFX_BaseSegmentedArray(int unit_size = 1, - int segment_units = 512, - int index_size = 8); - - ~CFX_BaseSegmentedArray(); - - void SetUnitSize(int unit_size, int segment_units, int index_size = 8); - - void* Add(); - - void* GetAt(int index) const; - - void RemoveAll(); - - void Delete(int index, int count = 1); - - int GetSize() const { return m_DataSize; } - - int GetSegmentSize() const { return m_SegmentSize; } - - int GetUnitSize() const { return m_UnitSize; } - - void* Iterate(FX_BOOL (*callback)(void* param, void* pData), - void* param) const; - - private: - int m_UnitSize; - - short m_SegmentSize; - - uint8_t m_IndexSize; - - uint8_t m_IndexDepth; - - int m_DataSize; - - void* m_pIndex; - void** GetIndex(int seg_index) const; - void* IterateIndex(int level, - int& start, - void** pIndex, - FX_BOOL (*callback)(void* param, void* pData), - void* param) const; - void* IterateSegment(const uint8_t* pSegment, - int count, - FX_BOOL (*callback)(void* param, void* pData), - void* param) const; -}; -template <class ElementType> -class CFX_SegmentedArray : public CFX_BaseSegmentedArray { - public: - CFX_SegmentedArray(int segment_units, int index_size = 8) - : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size) { - } - - void Add(ElementType data) { - *(ElementType*)CFX_BaseSegmentedArray::Add() = data; - } - - ElementType& operator[](int index) { - return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index); - } -}; #endif // PDF_ENABLE_XFA template <class DataType, int FixedSize> |