diff options
author | Robin Watts <robin.watts@artifex.com> | 2014-12-29 19:07:48 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2014-12-29 19:10:46 +0000 |
commit | 319c9d2315ad4fb13abe423571311ddb63202e2c (patch) | |
tree | 803e5a6cd31e500add8ec0bb8236277267a731a9 /source/pdf/pdf-stream.c | |
parent | 7209f8811b61007f999afcb78d4440a805d853f4 (diff) | |
download | mupdf-319c9d2315ad4fb13abe423571311ddb63202e2c.tar.xz |
Performance optimisation with pdf_cache_object/pdf_get_xref_entry
The recent change to holding pdf xrefs in a sparse format has resulted
in a significant decrease in speed (x10). Malc points out that some of
this (2x) can be recovered simply by making pdf_cache_object return the
entry which it found the object in.
This saves us having to immediately call pdf_get_xref_entry again
afterwards.
I am still thinking about ways to try and get the remaining time back.
Diffstat (limited to 'source/pdf/pdf-stream.c')
-rw-r--r-- | source/pdf/pdf-stream.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/source/pdf/pdf-stream.c b/source/pdf/pdf-stream.c index eb6b616e..f859719b 100644 --- a/source/pdf/pdf-stream.c +++ b/source/pdf/pdf-stream.c @@ -11,9 +11,8 @@ pdf_is_stream(pdf_document *doc, int num, int gen) if (num <= 0 || num >= pdf_xref_len(doc)) return 0; - pdf_cache_object(doc, num, gen); + entry = pdf_cache_object(doc, num, gen); - entry = pdf_get_xref_entry(doc, num); return entry->stm_ofs != 0 || entry->stm_buf; } @@ -408,9 +407,7 @@ pdf_open_raw_renumbered_stream(pdf_document *doc, int num, int gen, int orig_num if (num <= 0 || num >= pdf_xref_len(doc)) fz_throw(doc->ctx, FZ_ERROR_GENERIC, "object id out of range (%d %d R)", num, gen); - pdf_cache_object(doc, num, gen); - - x = pdf_get_xref_entry(doc, num); + x = pdf_cache_object(doc, num, gen); if (x->stm_ofs == 0) fz_throw(doc->ctx, FZ_ERROR_GENERIC, "object is not a stream"); @@ -425,9 +422,7 @@ pdf_open_image_stream(pdf_document *doc, int num, int gen, int orig_num, int ori if (num <= 0 || num >= pdf_xref_len(doc)) fz_throw(doc->ctx, FZ_ERROR_GENERIC, "object id out of range (%d %d R)", num, gen); - pdf_cache_object(doc, num, gen); - - x = pdf_get_xref_entry(doc, num); + x = pdf_cache_object(doc, num, gen); if (x->stm_ofs == 0 && x->stm_buf == NULL) fz_throw(doc->ctx, FZ_ERROR_GENERIC, "object is not a stream"); |