summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-02-24 19:55:24 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-02-24 19:55:24 +0000
commit6d614b5deac0d1605c61c8edf932d08b21a91bce (patch)
tree6a3d063721177feac92969bb74887ea721c1adfa
parent45ce923b2bef3cea4207b35285756dde72d3fdc8 (diff)
downloadpango-6d614b5deac0d1605c61c8edf932d08b21a91bce.tar.gz
Rewrite to reduce the number of strcmps.
Sun Feb 24 13:40:55 2002 Owen Taylor <otaylor@redhat.com> * pango/pangoxft-fontmap.c (pango_xft_pattern_equal): Rewrite to reduce the number of strcmps. * pango/pangoxft-fontmap.c (pango_xft_font_map_load_font): Compute the patterns as for load_fontset(), then just return the first. This takes advantage of our caching strategy.
-rw-r--r--pango/pangoxft-fontmap.c85
1 files changed, 41 insertions, 44 deletions
diff --git a/pango/pangoxft-fontmap.c b/pango/pangoxft-fontmap.c
index 62be892e..bd7c2ec0 100644
--- a/pango/pangoxft-fontmap.c
+++ b/pango/pangoxft-fontmap.c
@@ -520,59 +520,19 @@ pango_xft_font_map_new_font (PangoFontMap *fontmap,
return (PangoFont *)_pango_xft_font_new (fontmap, XftPatternDuplicate (match));
}
-static PangoFont *
-pango_xft_font_map_load_font (PangoFontMap *fontmap,
- PangoContext *context,
- const PangoFontDescription *description)
-{
- PangoXftFontMap *xfontmap = (PangoXftFontMap *)fontmap;
- XftPattern *pattern, *match;
- XftResult res;
- PangoFont *font = NULL;
-
- pattern = pango_xft_make_pattern (description);
-
- match = XftFontMatch (xfontmap->display, xfontmap->screen, pattern, &res);
-
- XftPatternDestroy (pattern);
-
- if (match)
- {
- font = pango_xft_font_map_new_font (fontmap, match);
- XftPatternDestroy (match);
- }
-
- return font;
-}
-
-
-static void
-pango_xft_font_set_free (PangoXftPatternSet *font_set)
-{
- int i;
-
- for (i = 0; i < font_set->n_patterns; i++)
- XftPatternDestroy (font_set->patterns[i]);
-
- g_free (font_set);
-}
-
-static PangoFontset *
-pango_xft_font_map_load_fontset (PangoFontMap *fontmap,
- PangoContext *context,
- const PangoFontDescription *desc,
- PangoLanguage *language)
+static PangoXftPatternSet *
+pango_xft_font_map_get_patterns (PangoFontMap *fontmap,
+ PangoContext *context,
+ const PangoFontDescription *desc)
{
PangoXftFontMap *xfontmap = (PangoXftFontMap *)fontmap;
XftPattern *pattern, *pattern_copy;
XftPattern *match;
- int i;
char *family, *family_res;
XftResult res;
int id;
GPtrArray *array;
PangoXftPatternSet *patterns;
- PangoFontsetSimple *simple;
patterns = g_hash_table_lookup (xfontmap->fontset_hash, desc);
@@ -642,7 +602,44 @@ pango_xft_font_map_load_fontset (PangoFontMap *fontmap,
patterns);
}
+ return patterns;
+}
+
+static PangoFont *
+pango_xft_font_map_load_font (PangoFontMap *fontmap,
+ PangoContext *context,
+ const PangoFontDescription *description)
+{
+ PangoXftPatternSet *patterns = pango_xft_font_map_get_patterns (fontmap, context, description);
+
+ if (patterns->n_patterns > 0)
+ return pango_xft_font_map_new_font (fontmap, patterns->patterns[0]);
+
+ return NULL;
+}
+
+static void
+pango_xft_font_set_free (PangoXftPatternSet *font_set)
+{
+ int i;
+ for (i = 0; i < font_set->n_patterns; i++)
+ XftPatternDestroy (font_set->patterns[i]);
+
+ g_free (font_set);
+}
+
+
+static PangoFontset *
+pango_xft_font_map_load_fontset (PangoFontMap *fontmap,
+ PangoContext *context,
+ const PangoFontDescription *desc,
+ PangoLanguage *language)
+{
+ PangoFontsetSimple *simple;
+ int i;
+ PangoXftPatternSet *patterns = pango_xft_font_map_get_patterns (fontmap, context, desc);
+
simple = pango_fontset_simple_new (language);
for (i = 0; i < patterns->n_patterns; i++)