diff options
author | Behdad Esfahbod <pango@behdad.org> | 2005-06-18 05:40:00 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2005-06-18 05:40:00 +0000 |
commit | 80c044cbf8d750d691ae2c8e2a9dbd4403e00297 (patch) | |
tree | ede2a62dc5545ec88db5e8b2cf8856aa4ae44d2a | |
parent | 0000711f8febb901f43798a56091276bb81574dc (diff) | |
download | pango-80c044cbf8d750d691ae2c8e2a9dbd4403e00297.tar.gz |
Optimization. Do not g_utf8_get_char at all. (#305323, Paolo Borelli)
2005-06-18 Behdad Esfahbod <pango@behdad.org>
* pango/break.c (pango_find_paragraph_boundary): Optimization.
Do not g_utf8_get_char at all. (#305323, Paolo Borelli)
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 11 | ||||
-rw-r--r-- | pango/break.c | 47 |
3 files changed, 42 insertions, 27 deletions
@@ -1,7 +1,12 @@ +2005-06-18 Behdad Esfahbod <pango@behdad.org> + + * pango/break.c (pango_find_paragraph_boundary): Optimization. + Do not g_utf8_get_char at all. (#305323, Paolo Borelli) + 2005-06-16 Owen Taylor <otaylor@redhat.com> * pango/pangocairo-fcfont.c (pango_cairo_fc_font_unlock_face): Remove - excess return (#307741, Damien Carbery) + excess return. (#307741, Damien Carbery) 2005-06-14 Owen Taylor <otaylor@redhat.com> @@ -11,7 +16,7 @@ 2005-06-14 Owen Taylor <otaylor@redhat.com> - Misc fixes from Stepan Kasal, #169928 + Misc fixes from Stepan Kasal, #169928 * pangoxft.pc.in: Add requirement on pangoft2 @@ -81,7 +86,7 @@ * pango/pango-context.c (itemize_state_finish): Fix potential leak of state->base_font. (#168930, Ben Maurer, - Aivars Kalvans) + Aivars Kalvans) 2005-06-10 Owen Taylor <otaylor@redhat.com> diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 089715b3..6e7c5223 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,7 +1,12 @@ +2005-06-18 Behdad Esfahbod <pango@behdad.org> + + * pango/break.c (pango_find_paragraph_boundary): Optimization. + Do not g_utf8_get_char at all. (#305323, Paolo Borelli) + 2005-06-16 Owen Taylor <otaylor@redhat.com> * pango/pangocairo-fcfont.c (pango_cairo_fc_font_unlock_face): Remove - excess return (#307741, Damien Carbery) + excess return. (#307741, Damien Carbery) 2005-06-14 Owen Taylor <otaylor@redhat.com> @@ -11,7 +16,7 @@ 2005-06-14 Owen Taylor <otaylor@redhat.com> - Misc fixes from Stepan Kasal, #169928 + Misc fixes from Stepan Kasal, #169928 * pangoxft.pc.in: Add requirement on pangoft2 @@ -81,7 +86,7 @@ * pango/pango-context.c (itemize_state_finish): Fix potential leak of state->base_font. (#168930, Ben Maurer, - Aivars Kalvans) + Aivars Kalvans) 2005-06-10 Owen Taylor <otaylor@redhat.com> diff --git a/pango/break.c b/pango/break.c index 8dcecec9..c9bef4b4 100644 --- a/pango/break.c +++ b/pango/break.c @@ -1411,12 +1411,20 @@ pango_find_paragraph_boundary (const gchar *text, const gchar *end; const gchar *start = NULL; const gchar *delimiter = NULL; - gunichar prev_wc; /* Only one character has type G_UNICODE_PARAGRAPH_SEPARATOR in - * Unicode 3.0; update this if that changes. + * Unicode 4.1; update the following code if that changes. + */ + + /* prev_sep is the first byte of the previous separator. Since + * the valid separators are \r, \n, and PARAGRAPH_SEPARATOR, the + * first byte is enough to identify it. */ + gchar prev_sep; + + #define PARAGRAPH_SEPARATOR 0x2029 +#define PARAGRAPH_SEPARATOR_STRING "\xE2\x80\xA9" if (length < 0) length = strlen (text); @@ -1432,29 +1440,21 @@ pango_find_paragraph_boundary (const gchar *text, if (length == 0) return; - /* FIXME there's plenty of room to optimize this; e.g. there's - * no real need to g_utf8_get_char() on every char - */ - - prev_wc = 0; + prev_sep = 0; while (p != end) { - gunichar wc; - - wc = g_utf8_get_char (p); - - if (prev_wc == '\n' || - prev_wc == PARAGRAPH_SEPARATOR) + if (prev_sep == '\n' || + prev_sep == PARAGRAPH_SEPARATOR_STRING[0]) { g_assert (delimiter); start = p; break; } - else if (prev_wc == '\r') + else if (prev_sep == '\r') { /* don't break between \r and \n */ - if (wc != '\n') + if (*p != '\n') { g_assert (delimiter); start = p; @@ -1462,13 +1462,18 @@ pango_find_paragraph_boundary (const gchar *text, } } - if ((wc == '\n' || - wc == '\r' || - wc == PARAGRAPH_SEPARATOR) && - delimiter == NULL) - delimiter = p; + if (*p == '\n' || + *p == '\r' || + !strncmp(p, PARAGRAPH_SEPARATOR_STRING, + strlen(PARAGRAPH_SEPARATOR_STRING))) + { + if (delimiter == NULL) + delimiter = p; + prev_sep = *p; + } + else + prev_sep = 0; - prev_wc = wc; p = g_utf8_next_char (p); } |