summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorPaul Gardiner <paulg.artifex@glidos.net>2013-06-27 15:31:29 +0100
committerRobin Watts <robin.watts@artifex.com>2013-06-28 19:26:42 +0100
commit063c7175976213010ce1c3c96c4d4b9703239eb0 (patch)
tree1f73d687af976b77b429a66c9ce050377e50cd4a /source/pdf
parentc256490e6927539522e2433e3b300515f85a25bf (diff)
downloadmupdf-063c7175976213010ce1c3c96c4d4b9703239eb0.tar.xz
Optimise xref-section extension and improve linked list creation
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-annot.c14
-rw-r--r--source/pdf/pdf-xref.c6
2 files changed, 9 insertions, 11 deletions
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index b66cdba0..5e50f0a2 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -477,7 +477,7 @@ static const char *annot_type_str(fz_annot_type type)
pdf_annot *
pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page)
{
- pdf_annot *annot, *head, *tail, **itr;
+ pdf_annot *annot, *head, **itr;
pdf_obj *obj, *ap, *as, *n, *rect;
int i, len, is_dict;
fz_context *ctx = doc->ctx;
@@ -486,7 +486,7 @@ pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page)
fz_var(itr);
fz_var(head);
- head = tail = NULL;
+ head = NULL;
len = pdf_array_len(annots);
/*
@@ -497,6 +497,7 @@ pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page)
*/
fz_try(ctx)
{
+ itr = &head;
for (i = 0; i < len; i++)
{
obj = pdf_array_get(annots, i);
@@ -505,13 +506,8 @@ pdf_load_annots(pdf_document *doc, pdf_obj *annots, pdf_page *page)
annot->page = page;
annot->next = NULL;
- if (!head)
- head = tail = annot;
- else
- {
- tail->next = annot;
- tail = annot;
- }
+ *itr = annot;
+ itr = &annot->next;
}
}
fz_catch(ctx)
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index cc4a076b..91083468 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -107,16 +107,18 @@ pdf_xref_entry *pdf_get_populating_xref_entry(pdf_document *doc, int num)
}
/* Ensure all xref sections map this entry */
- for (i = 0; i < doc->num_xref_sections; i++)
+ for (i = doc->num_xref_sections - 1; i >= 0; i--)
{
xref = &doc->xref_sections[i];
if (num >= xref->len)
pdf_resize_xref(doc->ctx, xref, num+1);
+ else
+ break; /* Remaining sections already of sufficient size */
}
/* Loop leaves xref pointing at the populating section */
- return &xref->table[num];
+ return &doc->xref_sections[doc->num_xref_sections-1].table[num];
}
/* Used after loading a document to access entries */