From 0bb2b5f4cf2264591657d2e0aead00955f9deb64 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 13 Sep 2015 11:26:19 -0400 Subject: 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 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pango/break.c b/pango/break.c index 1cc735cf..b4b3c822 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. */ -- cgit v1.2.1