summaryrefslogtreecommitdiff
path: root/src/cairo-font-face.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-font-face.c')
-rw-r--r--src/cairo-font-face.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c
index 6cea3958..a78c2aab 100644
--- a/src/cairo-font-face.c
+++ b/src/cairo-font-face.c
@@ -398,7 +398,7 @@ _cairo_toy_font_face_init (cairo_toy_font_face_t *font_face,
char *family_copy;
family_copy = strdup (family);
- if (family_copy == NULL)
+ if (unlikely (family_copy == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
_cairo_toy_font_face_init_key (font_face, family_copy,
@@ -467,10 +467,12 @@ cairo_toy_font_face_create (const char *family,
/* Make sure we've got valid UTF-8 for the family */
status = _cairo_utf8_to_ucs4 (family, -1, NULL, NULL);
- if (status == CAIRO_STATUS_INVALID_STRING)
- return (cairo_font_face_t*) &_cairo_font_face_invalid_string;
- else if (status)
+ if (unlikely (status)) {
+ if (status == CAIRO_STATUS_INVALID_STRING)
+ return (cairo_font_face_t*) &_cairo_font_face_invalid_string;
+
return (cairo_font_face_t*) &_cairo_font_face_nil;
+ }
switch (slant) {
case CAIRO_FONT_SLANT_NORMAL:
@@ -493,17 +495,16 @@ cairo_toy_font_face_create (const char *family,
family = CAIRO_FONT_FAMILY_DEFAULT;
hash_table = _cairo_toy_font_face_hash_table_lock ();
- if (hash_table == NULL)
+ if (unlikely (hash_table == NULL))
goto UNWIND;
_cairo_toy_font_face_init_key (&key, family, slant, weight);
/* Return existing font_face if it exists in the hash table. */
- if (_cairo_hash_table_lookup (hash_table,
- &key.base.hash_entry,
- (cairo_hash_entry_t **) &font_face))
- {
- if (! font_face->base.status) {
+ font_face = _cairo_hash_table_lookup (hash_table,
+ &key.base.hash_entry);
+ if (font_face != NULL) {
+ if (font_face->base.status == CAIRO_STATUS_SUCCESS) {
/* We increment the reference count here manually to avoid
double-locking. */
_cairo_reference_count_inc (&font_face->base.ref_count);
@@ -512,23 +513,23 @@ cairo_toy_font_face_create (const char *family,
}
/* remove the bad font from the hash table */
- _cairo_hash_table_remove (hash_table, &key.base.hash_entry);
+ _cairo_hash_table_remove (hash_table, &font_face->base.hash_entry);
font_face->base.hash_entry.hash = 0;
}
/* Otherwise create it and insert into hash table. */
font_face = malloc (sizeof (cairo_toy_font_face_t));
- if (font_face == NULL) {
+ if (unlikely (font_face == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto UNWIND_HASH_TABLE_LOCK;
}
status = _cairo_toy_font_face_init (font_face, family, slant, weight);
- if (status)
+ if (unlikely (status))
goto UNWIND_FONT_FACE_MALLOC;
status = _cairo_hash_table_insert (hash_table, &font_face->base.hash_entry);
- if (status)
+ if (unlikely (status))
goto UNWIND_FONT_FACE_INIT;
_cairo_toy_font_face_hash_table_unlock ();
@@ -615,7 +616,7 @@ _cairo_toy_font_face_scaled_font_create (void *abstract_font_face
return font_face->base.status;
status = cairo_font_options_status ((cairo_font_options_t *) options);
- if (status)
+ if (unlikely (status))
return status;
if (CAIRO_SCALED_FONT_BACKEND_DEFAULT != &_cairo_user_scaled_font_backend &&