summaryrefslogtreecommitdiff
path: root/src/cairo-cff-subset.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-11-07 20:30:33 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-11-07 20:50:34 +0000
commit2b32c8b9e572c96ce8ba5c7d43b568f18f6da295 (patch)
tree5bbac3fa688087fb74d3598105dd50786c68816c /src/cairo-cff-subset.c
parentd15fb9344bf86dd52cda0b43d3dfc49397fd84ec (diff)
[hash] Return lookup entry.
Use the return value to return the result from _cairo_hash_table_lookup() (as opposed to filling an output parameter on the stack) as this (a) results in cleaner code (no strict-alias breaking pointer casts), (b) produces a smaller binary and (c) is measurably faster.
Diffstat (limited to 'src/cairo-cff-subset.c')
-rw-r--r--src/cairo-cff-subset.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index 9a4e3d6a..45be5d1c 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -529,9 +529,8 @@ cff_dict_remove (cairo_hash_table_t *dict, unsigned short operator)
cff_dict_operator_t key, *op;
_cairo_dict_init_key (&key, operator);
- if (_cairo_hash_table_lookup (dict, &key.base,
- (cairo_hash_entry_t **) &op))
- {
+ op = _cairo_hash_table_lookup (dict, &key.base);
+ if (op != NULL) {
free (op->operand);
_cairo_hash_table_remove (dict, (cairo_hash_entry_t *) op);
free (op);
@@ -546,9 +545,8 @@ cff_dict_get_operands (cairo_hash_table_t *dict,
cff_dict_operator_t key, *op;
_cairo_dict_init_key (&key, operator);
- if (_cairo_hash_table_lookup (dict, &key.base,
- (cairo_hash_entry_t **) &op))
- {
+ op = _cairo_hash_table_lookup (dict, &key.base);
+ if (op != NULL) {
*size = op->operand_length;
return op->operand;
}
@@ -566,9 +564,8 @@ cff_dict_set_operands (cairo_hash_table_t *dict,
cairo_status_t status;
_cairo_dict_init_key (&key, operator);
- if (_cairo_hash_table_lookup (dict, &key.base,
- (cairo_hash_entry_t **) &op))
- {
+ op = _cairo_hash_table_lookup (dict, &key.base);
+ if (op != NULL) {
free (op->operand);
op->operand = malloc (size);
if (op->operand == NULL)
@@ -599,9 +596,8 @@ cff_dict_get_location (cairo_hash_table_t *dict,
cff_dict_operator_t key, *op;
_cairo_dict_init_key (&key, operator);
- if (_cairo_hash_table_lookup (dict, &key.base,
- (cairo_hash_entry_t **) &op))
- {
+ op = _cairo_hash_table_lookup (dict, &key.base);
+ if (op != NULL) {
*size = op->operand_length;
return op->operand_offset;
}
@@ -660,8 +656,8 @@ cff_dict_write (cairo_hash_table_t *dict, cairo_array_t *output)
/* The CFF specification requires that the Top Dict of CID fonts
* begin with the ROS operator. */
_cairo_dict_init_key (&key, ROS_OP);
- if (_cairo_hash_table_lookup (dict, &key.base,
- (cairo_hash_entry_t **) &op))
+ op = _cairo_hash_table_lookup (dict, &key.base);
+ if (op != NULL)
cairo_dict_write_operator (op, &write_info);
_cairo_hash_table_foreach (dict, _cairo_dict_collect, &write_info);