From 2032c57a56631435de30df689fc78939f1650bf8 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 13 Jun 2012 16:29:58 +0100 Subject: Tweak pdf_new_{rect,matrix,xobject} to avoid warnings. These functions currently call pdf_array_put, but this fails to extend the array. Change to use pdf_array_push instead. --- pdf/pdf_object.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'pdf/pdf_object.c') diff --git a/pdf/pdf_object.c b/pdf/pdf_object.c index 60f10a54..2f96f213 100644 --- a/pdf/pdf_object.c +++ b/pdf/pdf_object.c @@ -579,22 +579,22 @@ pdf_obj *pdf_new_rect(fz_context *ctx, fz_rect *rect) arr = pdf_new_array(ctx, 4); item = pdf_new_real(ctx, rect->x0); - pdf_array_put(arr, 0, item); + pdf_array_push(arr, item); pdf_drop_obj(item); item = NULL; item = pdf_new_real(ctx, rect->y0); - pdf_array_put(arr, 1, item); + pdf_array_push(arr, item); pdf_drop_obj(item); item = NULL; item = pdf_new_real(ctx, rect->x1 - rect->x0); - pdf_array_put(arr, 2, item); + pdf_array_push(arr, item); pdf_drop_obj(item); item = NULL; item = pdf_new_real(ctx, rect->y1 - rect->y0); - pdf_array_put(arr, 3, item); + pdf_array_push(arr, item); pdf_drop_obj(item); item = NULL; } @@ -620,32 +620,32 @@ pdf_obj *pdf_new_matrix(fz_context *ctx, fz_matrix *mtx) arr = pdf_new_array(ctx, 6); item = pdf_new_real(ctx, mtx->a); - pdf_array_put(arr, 0, item); + pdf_array_push(arr, item); pdf_drop_obj(item); item = NULL; item = pdf_new_real(ctx, mtx->b); - pdf_array_put(arr, 1, item); + pdf_array_push(arr, item); pdf_drop_obj(item); item = NULL; item = pdf_new_real(ctx, mtx->c); - pdf_array_put(arr, 2, item); + pdf_array_push(arr, item); pdf_drop_obj(item); item = NULL; item = pdf_new_real(ctx, mtx->d); - pdf_array_put(arr, 3, item); + pdf_array_push(arr, item); pdf_drop_obj(item); item = NULL; item = pdf_new_real(ctx, mtx->e); - pdf_array_put(arr, 4, item); + pdf_array_push(arr, item); pdf_drop_obj(item); item = NULL; item = pdf_new_real(ctx, mtx->f); - pdf_array_put(arr, 5, item); + pdf_array_push(arr, item); pdf_drop_obj(item); item = NULL; } -- cgit v1.2.3 From f23e5052e23a42057ef2c4025a38b9fc29ccd00c Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 4 Jul 2012 16:50:36 +0100 Subject: 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. --- pdf/pdf_object.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pdf/pdf_object.c') 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; -- cgit v1.2.3