Chromium Code Reviews| Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp |
| diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp |
| index 4aa99d08e33ace4766b20d12d3b3528e6d234784..76c4c0f5efadeb10e752673c2b2ebf6d2c0df932 100644 |
| --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp |
| +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp |
| @@ -2817,7 +2817,7 @@ class CPDF_DataAvail final : public IPDF_DataAvail { |
| CPDF_Document* m_pDocument; |
| - CPDF_SortObjNumArray m_objnum_array; |
| + std::set<FX_DWORD> m_objnum_set; |
|
Tom Sepez
2016/01/06 00:49:56
nit: the naming convention for a class that is dir
Lei Zhang
2016/01/06 00:52:26
m_ObjectSet it is.
|
| CFX_ArrayTemplate<CPDF_Object*> m_objs_array; |
| @@ -3059,8 +3059,8 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail( |
| if (!IsDataAvail(offset, size, pHints)) { |
| ret_array.Add(pObj); |
| count++; |
| - } else if (!m_objnum_array.Find(dwNum)) { |
| - m_objnum_array.AddObjNum(dwNum); |
| + } else if (!pdfium::ContainsKey(m_objnum_set, dwNum)) { |
| + m_objnum_set.insert(dwNum); |
| CPDF_Object* pReferred = |
| m_pDocument->GetIndirectObject(pRef->GetRefObjNum(), NULL); |
| if (pReferred) { |
| @@ -3076,7 +3076,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail( |
| CPDF_Object* pObj = new_obj_array[i]; |
| if (CPDF_Reference* pRef = pObj->AsReference()) { |
| FX_DWORD dwNum = pRef->GetRefObjNum(); |
| - if (!m_objnum_array.Find(dwNum)) |
| + if (!pdfium::ContainsKey(m_objnum_set, dwNum)) |
| ret_array.Add(pObj); |
| } else { |
| ret_array.Add(pObj); |
| @@ -3108,7 +3108,7 @@ IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail( |
| FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints) { |
| if (!m_objs_array.GetSize()) { |
| m_objs_array.RemoveAll(); |
| - m_objnum_array.RemoveAll(); |
| + m_objnum_set.clear(); |
| CFX_ArrayTemplate<CPDF_Object*> obj_array; |
| obj_array.Append(m_arrayAcroforms); |
| FX_BOOL bRet = IsObjectsAvail(obj_array, FALSE, pHints, m_objs_array); |
| @@ -4314,7 +4314,7 @@ FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage, |
| IFX_DownloadHints* pHints) { |
| if (!m_objs_array.GetSize()) { |
| m_objs_array.RemoveAll(); |
| - m_objnum_array.RemoveAll(); |
| + m_objnum_set.clear(); |
| CPDF_Dictionary* pPageDict = m_pDocument->GetPage(iPage); |
| if (!pPageDict) { |
| return TRUE; |
| @@ -4384,7 +4384,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) { |
| m_bAnnotsLoad = FALSE; |
| m_bNeedDownLoadResource = FALSE; |
| m_objs_array.RemoveAll(); |
| - m_objnum_array.RemoveAll(); |
| + m_objnum_set.clear(); |
| } |
| if (pdfium::ContainsKey(m_pagesLoadState, iPage)) |
| return DataAvailable; |
| @@ -4441,7 +4441,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) { |
| if (!m_bPageLoadedOK) { |
| if (!m_objs_array.GetSize()) { |
| m_objs_array.RemoveAll(); |
| - m_objnum_array.RemoveAll(); |
| + m_objnum_set.clear(); |
| m_pPageDict = m_pDocument->GetPage(iPage); |
| if (!m_pPageDict) { |
| ResetFirstCheck(iPage); |
| @@ -4595,35 +4595,7 @@ IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail( |
| } |
| return FormAvailable; |
| } |
| -void CPDF_SortObjNumArray::AddObjNum(FX_DWORD dwObjNum) { |
| - int32_t iNext = 0; |
| - if (BinarySearch(dwObjNum, iNext)) { |
| - return; |
| - } |
| - m_number_array.InsertAt(iNext, dwObjNum); |
| -} |
| -FX_BOOL CPDF_SortObjNumArray::Find(FX_DWORD dwObjNum) { |
| - int32_t iNext = 0; |
| - return BinarySearch(dwObjNum, iNext); |
| -} |
| -FX_BOOL CPDF_SortObjNumArray::BinarySearch(FX_DWORD value, int32_t& iNext) { |
| - int32_t iLow = 0; |
| - int32_t iHigh = m_number_array.GetSize() - 1; |
| - while (iLow <= iHigh) { |
| - int32_t iMid = (iLow + iHigh) / 2; |
| - if (m_number_array.GetAt(iMid) == value) { |
| - iNext = iMid; |
| - return TRUE; |
| - } |
| - if (m_number_array.GetAt(iMid) > value) { |
| - iHigh = iMid - 1; |
| - } else if (m_number_array.GetAt(iMid) < value) { |
| - iLow = iMid + 1; |
| - } |
| - } |
| - iNext = iLow; |
| - return FALSE; |
| -} |
| + |
| CPDF_PageNode::~CPDF_PageNode() { |
| for (int32_t i = 0; i < m_childNode.GetSize(); ++i) { |
| delete m_childNode[i]; |