Skip to content

poppler/Catalog: map page by Ref to make findPage() faster (#1485)

Hubert Figuiere requested to merge hub/poppler:find-page-speedup into master

findPage used to iterate linearly to find a page by Ref, instead we use a map.

See #1485

Signed-off-by: Hubert Figuière hub@figuiere.net

This is a followup on !1554 (merged)

This time we stop iterating through all the pages to find one by Ref. Instead, cachePageTree add them to an unordered map that map Ref to page numbers.

This shave off 10-15sec on my test, possibly 15+sec

The code is mostly splitting out cachePageTree to implement cachePageTreeByRef() which will return the page index for the ref after caching the page tree, which add the unordered_map to the catalog. The extra memory used by the struct shouldn't be significant as it's in the catalog.

Merge request reports