diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2007-02-05 13:38:56 +0000 |
---|---|---|
committer | Chris Wilson <cpwilson@src.gnome.org> | 2007-02-05 13:38:56 +0000 |
commit | 25007669b49652093e6d14699e5d5a4b15a77ce8 (patch) | |
tree | 29854e1c0d0514852a4672d257f8f99ce1832246 /src/iso2022.c | |
parent | 589e6df7291dae65b02fe9223f40c916e2c4ade7 (diff) | |
download | vte-25007669b49652093e6d14699e5d5a4b15a77ce8.tar.gz |
Some more small callgrind tweaks - well into the law of diminishing
2007-02-05 Chris Wilson <chris@chris-wilson.co.uk>
Some more small callgrind tweaks - well into the law of diminishing
returns.
* src/iso2022.c: (_vte_iso2022_is_ambiguous_ht),
(_vte_iso2022_is_ambiguous), (process_8_bit_sequence),
(process_cdata), (_vte_iso2022_unichar_width):
* src/matcher.c: (_vte_matcher_free_params_array):
* src/vte.c: (vte_terminal_process_incoming):
svn path=/trunk/; revision=1625
Diffstat (limited to 'src/iso2022.c')
-rw-r--r-- | src/iso2022.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/iso2022.c b/src/iso2022.c index 1cd61a2b..def4e99e 100644 --- a/src/iso2022.c +++ b/src/iso2022.c @@ -286,11 +286,25 @@ _vte_direct_compare(gconstpointer a, gconstpointer b) } static gboolean +_vte_iso2022_is_ambiguous_ht(gunichar c) +{ + static GHashTable *ambiguous; + if (!ambiguous) { + gpointer p; + gsize i; + ambiguous = g_hash_table_new (NULL, NULL); + for (i = 0; i < G_N_ELEMENTS(_vte_iso2022_ambiguous_chars); i++) { + p = GINT_TO_POINTER(_vte_iso2022_ambiguous_chars[i]); + g_hash_table_insert(ambiguous, p, p); + } + } + + return g_hash_table_lookup(ambiguous, GINT_TO_POINTER(c)) != NULL; +} +static inline gboolean _vte_iso2022_is_ambiguous(gunichar c) { gsize i; - gpointer p; - static GHashTable *ambiguous = NULL; for (i = 0; i < G_N_ELEMENTS(_vte_iso2022_unambiguous_ranges); i++) { if ((c >= _vte_iso2022_unambiguous_ranges[i].start) && (c <= _vte_iso2022_unambiguous_ranges[i].end)) { @@ -303,16 +317,7 @@ _vte_iso2022_is_ambiguous(gunichar c) return TRUE; } } - if (!ambiguous) { - ambiguous = g_hash_table_new (NULL, NULL); - - for (i = 0; i < G_N_ELEMENTS(_vte_iso2022_ambiguous_chars); i++) { - p = GINT_TO_POINTER(_vte_iso2022_ambiguous_chars[i]); - g_hash_table_insert(ambiguous, p, p); - } - } - - return g_hash_table_lookup(ambiguous, GINT_TO_POINTER(c)) != NULL; + return _vte_iso2022_is_ambiguous_ht (c); } /* If we only have a codepoint, guess what the ambiguous width should be based @@ -1173,7 +1178,7 @@ process_8_bit_sequence(struct _vte_iso2022_state *state, if (force_width != 0) { width = force_width; } else { - if (_vte_iso2022_is_ambiguous(c)) { + if (G_UNLIKELY (_vte_iso2022_is_ambiguous(c))) { width = state->ambiguous_width; } } @@ -1286,7 +1291,7 @@ process_cdata(struct _vte_iso2022_state *state, const guchar *cdata, gsize lengt /* Skip the padding character. */ continue; } - if (_vte_iso2022_is_ambiguous(c)) { + if (G_UNLIKELY (_vte_iso2022_is_ambiguous(c))) { width = ambiguous_width; c = _vte_iso2022_set_encoded_width(c, width); } @@ -1324,7 +1329,7 @@ process_cdata(struct _vte_iso2022_state *state, const guchar *cdata, gsize lengt if (force_width != 0) { width = force_width; } else { - if (_vte_iso2022_is_ambiguous(c)) { + if (G_UNLIKELY (_vte_iso2022_is_ambiguous(c))) { width = ambiguous_width; } } @@ -1698,7 +1703,7 @@ gssize _vte_iso2022_unichar_width(gunichar c) { c = c & ~(VTE_ISO2022_ENCODED_WIDTH_MASK); /* just in case */ - if (_vte_iso2022_is_ambiguous(c)) { + if (G_UNLIKELY (_vte_iso2022_is_ambiguous(c))) { return _vte_iso2022_ambiguous_width_guess(); } if (g_unichar_iswide(c)) { |