diff options
author | Matthias Clasen <mclasen@redhat.com> | 2005-12-12 19:16:00 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2005-12-12 19:16:00 +0000 |
commit | 104772f87a3aab04672bdf114cae06788e4e89dc (patch) | |
tree | 1b017bc585726748c0b2a094382c8d32a82456d6 /gtk/gtktextbtree.c | |
parent | dd3a8cd122ca7fc3bf80a2bf394dae8b2f36934e (diff) | |
download | gtk+-104772f87a3aab04672bdf114cae06788e4e89dc.tar.gz |
Speed up stepping backwards. (#320638, Larry Ewing, Paolo Borelli)
2005-12-12 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktextbtree.c (_gtk_text_line_char_to_byte_offsets):
* gtk/gtktextiter.c (gtk_text_iter_backward_chars): Speed up
stepping backwards. (#320638, Larry Ewing, Paolo Borelli)
Diffstat (limited to 'gtk/gtktextbtree.c')
-rw-r--r-- | gtk/gtktextbtree.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c index c323c713fa..f9b25b3f78 100644 --- a/gtk/gtktextbtree.c +++ b/gtk/gtktextbtree.c @@ -4146,7 +4146,12 @@ _gtk_text_line_char_to_byte_offsets (GtkTextLine *line, { const char *p; - p = g_utf8_offset_to_pointer (seg->body.chars, offset); + /* if in the last fourth of the segment walk backwards */ + if (seg->char_count - offset < seg->char_count / 4) + p = g_utf8_offset_to_pointer (seg->body.chars + seg->byte_count, + offset - seg->char_count); + else + p = g_utf8_offset_to_pointer (seg->body.chars, offset); *seg_byte_offset = p - seg->body.chars; |