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 /apps | |
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 'apps')
-rw-r--r-- | apps/mupdfclean.c | 3 | ||||
-rw-r--r-- | apps/mupdfextract.c | 3 | ||||
-rw-r--r-- | apps/mupdfshow.c | 5 |
3 files changed, 7 insertions, 4 deletions
diff --git a/apps/mupdfclean.c b/apps/mupdfclean.c index 8eb30efe..264d8edc 100644 --- a/apps/mupdfclean.c +++ b/apps/mupdfclean.c @@ -123,8 +123,9 @@ static void retainpages(int argc, char **argv) pdf_obj *names = pdf_new_dict(ctx, 1); pdf_obj *dests = pdf_new_dict(ctx, 1); pdf_obj *names_list = pdf_new_array(ctx, 32); + int len = pdf_dict_len(olddests); - for (i = 0; i < pdf_dict_len(olddests); i++) + for (i = 0; i < len; i++) { pdf_obj *key = pdf_dict_get_key(olddests, i); pdf_obj *val = pdf_dict_get_val(olddests, i); diff --git a/apps/mupdfextract.c b/apps/mupdfextract.c index 8db6ceaf..95f27be9 100644 --- a/apps/mupdfextract.c +++ b/apps/mupdfextract.c @@ -178,7 +178,8 @@ int pdfextract_main(int argc, char **argv) if (fz_optind == argc) { - for (o = 0; o < pdf_count_objects(doc); o++) + int len = pdf_count_objects(doc); + for (o = 0; o < len; o++) showobject(o); } else diff --git a/apps/mupdfshow.c b/apps/mupdfshow.c index 252e7dc2..8e8425b0 100644 --- a/apps/mupdfshow.c +++ b/apps/mupdfshow.c @@ -142,9 +142,10 @@ static void showobject(int num, int gen) static void showgrep(char *filename) { pdf_obj *obj; - int i; + int i, len; - for (i = 0; i < pdf_count_objects(doc); i++) + len = pdf_count_objects(doc); + for (i = 0; i < len; i++) { if (doc->table[i].type == 'n' || doc->table[i].type == 'o') { |