diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-07-04 16:50:36 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-07-05 11:01:51 +0100 |
commit | f23e5052e23a42057ef2c4025a38b9fc29ccd00c (patch) | |
tree | 8b43a48b380fb5a37eeb1910d1b91834bb6313f7 /pdf | |
parent | 808e051272c2a0b1e32e252fd14cdaf65c452132 (diff) | |
download | mupdf-f23e5052e23a42057ef2c4025a38b9fc29ccd00c.tar.xz |
Avoid calling pdf_array_len (and friends) in a loop.
for(i = 0; i < pdf_array_len(x); i++)
...
results in lots of calls to pdf_array_len. This is not what we want.
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/pdf_nametree.c | 6 | ||||
-rw-r--r-- | pdf/pdf_object.c | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/pdf/pdf_nametree.c b/pdf/pdf_nametree.c index 73755e22..7d8ac319 100644 --- a/pdf/pdf_nametree.c +++ b/pdf/pdf_nametree.c @@ -120,14 +120,16 @@ pdf_load_name_tree_imp(pdf_obj *dict, pdf_document *xref, pdf_obj *node) if (kids && !pdf_dict_mark(node)) { - for (i = 0; i < pdf_array_len(kids); i++) + int len = pdf_array_len(kids); + for (i = 0; i < len; i++) pdf_load_name_tree_imp(dict, xref, pdf_array_get(kids, i)); pdf_dict_unmark(node); } if (names) { - for (i = 0; i + 1 < pdf_array_len(names); i += 2) + int len = pdf_array_len(names); + for (i = 0; i + 1 < len; i += 2) { pdf_obj *key = pdf_array_get(names, i); pdf_obj *val = pdf_array_get(names, i + 1); diff --git a/pdf/pdf_object.c b/pdf/pdf_object.c index 2f96f213..531eb8eb 100644 --- a/pdf/pdf_object.c +++ b/pdf/pdf_object.c @@ -558,9 +558,10 @@ pdf_array_insert(pdf_obj *obj, pdf_obj *item) int pdf_array_contains(pdf_obj *arr, pdf_obj *obj) { - int i; + int i, len; - for (i = 0; i < pdf_array_len(arr); i++) + len = pdf_array_len(arr); + for (i = 0; i < len; i++) if (!pdf_objcmp(pdf_array_get(arr, i), obj)) return 1; |