[pango] Avoid some overhead in pango_default_break
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] Avoid some overhead in pango_default_break
- Date: Sun, 13 Sep 2015 15:31:28 +0000 (UTC)
commit 0bb2b5f4cf2264591657d2e0aead00955f9deb64
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Sep 13 11:26:19 2015 -0400
Avoid some overhead in pango_default_break
We already have the Unicode type, so we can determine
isspace without doing the full type determination again.
pango/break.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/pango/break.c b/pango/break.c
index 1cc735c..b4b3c82 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -639,10 +639,20 @@ pango_default_break (const gchar *text,
makes_hangul_syllable = (prev_end == this_start) || (prev_end + 1 == this_start);
}
- /* Can't just use the type here since isspace() doesn't
- * correspond to a Unicode character type
- */
- attrs[i].is_white = g_unichar_isspace (wc);
+ switch (type)
+ {
+ case G_UNICODE_SPACE_SEPARATOR:
+ case G_UNICODE_LINE_SEPARATOR:
+ case G_UNICODE_PARAGRAPH_SEPARATOR:
+ attrs[i].is_white = TRUE;
+ break;
+ default:
+ if (wc == '\t' || wc == '\n' || wc == '\r' || wc == '\f')
+ attrs[i].is_white = TRUE;
+ else
+ attrs[i].is_white = FALSE;
+ break;
+ }
/* Just few spaces have variable width. So explicitly mark them.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]