summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_document.h
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-10-28 14:30:44 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-28 14:30:44 -0700
commit900f421e29daf2ab62de3ae8dc821f031bc7bdb3 (patch)
tree7f9020dd8a2172b523d8a35864a5c6b0053ec658 /core/fpdfapi/parser/cpdf_document.h
parentdc0401a0da446a0744419d71f2bb216f3b90ad0f (diff)
downloadpdfium-900f421e29daf2ab62de3ae8dc821f031bc7bdb3.tar.xz
Revert of Traverse PDF page tree only once in CPDF_Document Try 2 (patchset #3 id:40001 of https://codereview.chromium.org/2442403002/ )
Reason for revert: Not quite right yet. Original issue's description: > Traverse PDF page tree only once in CPDF_Document > > Try 2: main fix was recursively popping elements from the stack. Since > the Traverse method can be called on non-root nodes from GetPage(), we > have to make sure to properly update the parents. > > Try 1 at https://codereview.chromium.org/2414423002/ > > In our current implementation of CPDF_Document::GetPage, we traverse > the PDF page tree until we find the index we are looking for. This is > slow when we do calls GetPage(0), GetPage(1), ... since in this case > the page tree will be traversed n times if there are n pages. This CL > makes sure the page tree is only traversed once. > > Time to load the PDF from the bug below in chrome official build: > Before this CL: around 1 minute 25 seconds > After this CL: around 4 seconds > > BUG=chromium:638513 > > Committed: https://pdfium.googlesource.com/pdfium/+/d3a2009d75eac3cda442f545ef0865afae7b35cf TBR=tsepez@chromium.org,weili@chromium.org,thestig@chromium.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=chromium:638513 Review-Url: https://codereview.chromium.org/2461063003
Diffstat (limited to 'core/fpdfapi/parser/cpdf_document.h')
-rw-r--r--core/fpdfapi/parser/cpdf_document.h21
1 files changed, 5 insertions, 16 deletions
diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h
index ef9f663c3b..ea7bd328aa 100644
--- a/core/fpdfapi/parser/cpdf_document.h
+++ b/core/fpdfapi/parser/cpdf_document.h
@@ -9,7 +9,6 @@
#include <functional>
#include <memory>
-#include <stack>
#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
#include "core/fpdfapi/parser/cpdf_object.h"
@@ -106,7 +105,10 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
protected:
// Retrieve page count information by getting count value from the tree nodes
int RetrievePageCount() const;
- CPDF_Dictionary* TraversePDFPages(int iPage, int nPagesToGo);
+ CPDF_Dictionary* FindPDFPage(CPDF_Dictionary* pPages,
+ int iPage,
+ int nPagesToGo,
+ int level);
int FindPageIndex(CPDF_Dictionary* pNode,
uint32_t& skip_count,
uint32_t objnum,
@@ -122,23 +124,10 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
FX_BOOL bVert,
CFX_ByteString basefont,
std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert);
- int InsertDeletePDFPage(CPDF_Dictionary* pPages,
- int nPagesToGo,
- CPDF_Dictionary* pPage,
- FX_BOOL bInsert,
- std::set<CPDF_Dictionary*>* pVisited);
- int InsertNewPage(int iPage,
- CPDF_Dictionary* pPageDict,
- CFX_ArrayTemplate<uint32_t>& pageList);
- void PopAndPropagate();
+
std::unique_ptr<CPDF_Parser> m_pParser;
CPDF_Dictionary* m_pRootDict;
CPDF_Dictionary* m_pInfoDict;
- // Stack of page nodes to know current position in page tree. Int is the index
- // of last processed child.
- std::stack<std::pair<CPDF_Dictionary*, int>> m_pTreeTraversal;
- // Index of last page (leaf) processed from page tree.
- int m_iLastPageTraversed;
bool m_bLinearized;
int m_iFirstPageNo;
uint32_t m_dwFirstPageObjNum;