summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-21 15:45:39 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-21 20:46:57 +0000
commit090e04147999da5f73f1866a6d55014504c47c9b (patch)
tree5491d92093be8a0d570548e1326dab149bd78bf0 /core/fxcrt
parent1fc6f6ebae5dae17a5af25856af061a56c670b1f (diff)
downloadpdfium-090e04147999da5f73f1866a6d55014504c47c9b.tar.xz
Replace CFX_FileSizeListArray with a std::map
This CL replaces the FileSizeListArray code with a std::map. Change-Id: Ic158ad95e7055693168d186ba428806a59b04c95 Reviewed-on: https://pdfium-review.googlesource.com/3136 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_basic.h124
1 files changed, 0 insertions, 124 deletions
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h
index a4069fddbd..ee630e100d 100644
--- a/core/fxcrt/fx_basic.h
+++ b/core/fxcrt/fx_basic.h
@@ -378,130 +378,6 @@ class CFX_AutoRestorer {
const T m_OldValue;
};
-#define FX_DATALIST_LENGTH 1024
-template <size_t unit>
-class CFX_SortListArray {
- protected:
- struct DataList {
- int32_t start;
-
- int32_t count;
- uint8_t* data;
- };
-
- public:
- CFX_SortListArray() : m_CurList(0) {}
-
- ~CFX_SortListArray() { Clear(); }
-
- void Clear() {
- for (int32_t i = m_DataLists.GetUpperBound(); i >= 0; i--) {
- DataList list = m_DataLists.ElementAt(i);
- FX_Free(list.data);
- }
- m_DataLists.RemoveAll();
- m_CurList = 0;
- }
-
- void Append(int32_t nStart, int32_t nCount) {
- if (nStart < 0) {
- return;
- }
- while (nCount > 0) {
- int32_t temp_count = std::min(nCount, FX_DATALIST_LENGTH);
- DataList list;
- list.data = FX_Alloc2D(uint8_t, temp_count, unit);
- list.start = nStart;
- list.count = temp_count;
- Append(list);
- nCount -= temp_count;
- nStart += temp_count;
- }
- }
-
- uint8_t* GetAt(int32_t nIndex) {
- if (nIndex < 0) {
- return nullptr;
- }
- if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) {
- return nullptr;
- }
- DataList* pCurList = m_DataLists.GetDataPtr(m_CurList);
- if (!pCurList || nIndex < pCurList->start ||
- nIndex >= pCurList->start + pCurList->count) {
- pCurList = nullptr;
- int32_t iStart = 0;
- int32_t iEnd = m_DataLists.GetUpperBound();
- int32_t iMid = 0;
- while (iStart <= iEnd) {
- iMid = (iStart + iEnd) / 2;
- DataList* list = m_DataLists.GetDataPtr(iMid);
- if (nIndex < list->start) {
- iEnd = iMid - 1;
- } else if (nIndex >= list->start + list->count) {
- iStart = iMid + 1;
- } else {
- pCurList = list;
- m_CurList = iMid;
- break;
- }
- }
- }
- return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit
- : nullptr;
- }
-
- protected:
- void Append(const DataList& list) {
- int32_t iStart = 0;
- int32_t iEnd = m_DataLists.GetUpperBound();
- int32_t iFind = 0;
- while (iStart <= iEnd) {
- int32_t iMid = (iStart + iEnd) / 2;
- DataList* cur_list = m_DataLists.GetDataPtr(iMid);
- if (list.start < cur_list->start + cur_list->count) {
- iEnd = iMid - 1;
- } else {
- if (iMid == iEnd) {
- iFind = iMid + 1;
- break;
- }
- DataList* next_list = m_DataLists.GetDataPtr(iMid + 1);
- if (list.start < next_list->start) {
- iFind = iMid + 1;
- break;
- } else {
- iStart = iMid + 1;
- }
- }
- }
- m_DataLists.InsertAt(iFind, list);
- }
- int32_t m_CurList;
- CFX_ArrayTemplate<DataList> m_DataLists;
-};
-template <typename T1, typename T2>
-class CFX_ListArrayTemplate {
- public:
- void Clear() { m_Data.Clear(); }
-
- void Add(int32_t nStart, int32_t nCount) { m_Data.Append(nStart, nCount); }
-
- T2& operator[](int32_t nIndex) {
- uint8_t* data = m_Data.GetAt(nIndex);
- ASSERT(data);
- return (T2&)(*(volatile T2*)data);
- }
-
- T2* GetPtrAt(int32_t nIndex) { return (T2*)m_Data.GetAt(nIndex); }
-
- protected:
- T1 m_Data;
-};
-typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_FILESIZE)>,
- FX_FILESIZE>
- CFX_FileSizeListArray;
-
class CFX_Vector_3by1 {
public:
CFX_Vector_3by1() : a(0.0f), b(0.0f), c(0.0f) {}