summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2015-03-25 14:59:06 +0000
committerRobin Watts <robin.watts@artifex.com>2015-03-25 15:35:43 +0000
commitfaff7d215d54359083fa8dccf5c9d08a29bb484b (patch)
tree12c0990feed5a8e7a1315fc88c1ae5c02d557615 /source
parent141bd24f0885b29ae50b36bd964b4e2f4c69f980 (diff)
downloadmupdf-faff7d215d54359083fa8dccf5c9d08a29bb484b.tar.xz
Avoid calling pdf_dict_finds when we could call pdf_dict_find.
Faster, shinier, better.
Diffstat (limited to 'source')
-rw-r--r--source/pdf/pdf-object.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c
index 5711cbaa..2a7ab618 100644
--- a/source/pdf/pdf-object.c
+++ b/source/pdf/pdf-object.c
@@ -1172,19 +1172,14 @@ pdf_dict_get(fz_context *ctx, pdf_obj *obj, pdf_obj *key)
{
int i;
- if (key >= PDF_OBJ__LIMIT)
- {
- if (key->kind != PDF_NAME)
- return NULL;
-
- return pdf_dict_gets(ctx, obj, pdf_to_name(ctx, key));
- }
-
RESOLVE(obj);
if (obj < PDF_OBJ__LIMIT || obj->kind != PDF_DICT)
return NULL;
- i = pdf_dict_find(ctx, obj, key, NULL);
+ if (key < PDF_OBJ__LIMIT)
+ i = pdf_dict_find(ctx, obj, key, NULL);
+ else
+ i = pdf_dict_finds(ctx, obj, pdf_to_name(ctx, key), NULL);
if (i >= 0)
return DICT(obj)->items[i].v;
return NULL;
@@ -1217,7 +1212,6 @@ pdf_dict_put(fz_context *ctx, pdf_obj *obj, pdf_obj *key, pdf_obj *val)
if (obj >= PDF_OBJ__LIMIT)
{
int location;
- char *s;
int i;
if (obj->kind != PDF_DICT)
@@ -1232,19 +1226,20 @@ pdf_dict_put(fz_context *ctx, pdf_obj *obj, pdf_obj *key, pdf_obj *val)
fz_warn(ctx, "assert: key is not a name (%s)", pdf_objkindstr(obj));
return;
}
- else
- s = pdf_to_name(ctx, key);
if (!val)
{
- fz_warn(ctx, "assert: val does not exist for key (%s)", s);
+ fz_warn(ctx, "assert: val does not exist for key (%s)", pdf_to_name(ctx, key));
return;
}
if (DICT(obj)->len > 100 && !(obj->flags & PDF_FLAGS_SORTED))
pdf_sort_dict(ctx, obj);
- i = pdf_dict_finds(ctx, obj, s, &location);
+ if (key < PDF_OBJ__LIMIT)
+ i = pdf_dict_find(ctx, obj, key, &location);
+ else
+ i = pdf_dict_finds(ctx, obj, pdf_to_name(ctx, key), &location);
if (i >= 0 && i < DICT(obj)->len)
{
if (DICT(obj)->items[i].v != val)