fastrefnums

This commit is contained in:
John Whitington 2017-05-29 14:02:34 +01:00
parent 88a40cb51f
commit 13c259ab2e
1 changed files with 6 additions and 2 deletions

View File

@ -1199,12 +1199,16 @@ let list_bookmarks encoding range pdf output =
in
let bookmarks = Pdfmarks.read_bookmarks pdf in
let refnums = Pdf.page_reference_numbers pdf in
let rangetable = hashset_of_list range in
let fastrefnums = hashtable_of_dictionary (combine refnums (indx refnums)) in
(* Find the pagenumber of each bookmark target. If it is in the range,
* keep that bookmark. Also keep the bookmark if its target is the null
* destination. *)
let inrange =
(* n ^ 2 here too? *)
keep
(function x ->
x.Pdfmarks.target = Pdfdest.NullDestination ||
mem (Pdfpage.pagenumber_of_target ~refnums pdf x.Pdfmarks.target) range) bookmarks
Hashtbl.mem rangetable (Pdfpage.pagenumber_of_target ~fastrefnums pdf x.Pdfmarks.target)) bookmarks
in
iter
(function mark ->