diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2013-06-28 17:08:40 +0200 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-07-11 10:46:40 +0100 |
commit | 1bf6c8ab8ab78faa9b67b8e4523faf7ab62f450e (patch) | |
tree | 1bef17cf17e367bf84f0ebb6aac09e165f3f2ca1 | |
parent | 9b3e229f1d590eb40e5fcc9357f8311b1968bc3a (diff) | |
download | mupdf-1bf6c8ab8ab78faa9b67b8e4523faf7ab62f450e.tar.xz |
Hoist count skipping up to before we recurse.
-rw-r--r-- | source/pdf/pdf-page.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c index c58995d6..5d92c3ef 100644 --- a/source/pdf/pdf-page.c +++ b/source/pdf/pdf-page.c @@ -16,15 +16,7 @@ pdf_lookup_page_loc_imp(pdf_document *doc, pdf_obj *node, int *skip, pdf_obj **p { fz_context *ctx = doc->ctx; pdf_obj *kids, *hit; - int i, len, count; - - count = pdf_to_int(pdf_dict_gets(node, "Count")); - if (*skip > count) - { - /* The princess is in another castle. */ - *skip -= count; - return NULL; - } + int i, len; kids = pdf_dict_gets(node, "Kids"); len = pdf_array_len(kids); @@ -57,9 +49,17 @@ pdf_lookup_page_loc_imp(pdf_document *doc, pdf_obj *node, int *skip, pdf_obj **p } else if (!strcmp(type, "Pages")) { - hit = pdf_lookup_page_loc_imp(doc, kid, skip, parentp, indexp); - if (hit) - break; + int count = pdf_to_int(pdf_dict_gets(kid, "Count")); + if (*skip < count) + { + hit = pdf_lookup_page_loc_imp(doc, kid, skip, parentp, indexp); + if (hit) + break; + } + else + { + *skip -= count; + } } else { |