summaryrefslogtreecommitdiff
path: root/gtk/gtktextiter.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2005-12-12 19:16:00 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2005-12-12 19:16:00 +0000
commit104772f87a3aab04672bdf114cae06788e4e89dc (patch)
tree1b017bc585726748c0b2a094382c8d32a82456d6 /gtk/gtktextiter.c
parentdd3a8cd122ca7fc3bf80a2bf394dae8b2f36934e (diff)
downloadgtk+-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/gtktextiter.c')
-rw-r--r--gtk/gtktextiter.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c
index fd5b4f4c8f..a2c099bfcf 100644
--- a/gtk/gtktextiter.c
+++ b/gtk/gtktextiter.c
@@ -2386,23 +2386,25 @@ gtk_text_iter_backward_chars (GtkTextIter *iter, gint count)
g_assert (real->segment->char_count > 0);
g_assert (real->segment->type == &gtk_text_char_type);
- real->segment_char_offset -= count;
- g_assert (real->segment_char_offset >= 0);
-
if (real->line_byte_offset >= 0)
{
const char *p;
gint new_byte_offset;
- gint i;
- p = g_utf8_offset_to_pointer (real->segment->body.chars,
- real->segment_char_offset);
+ /* if in the last fourth of the segment walk backwards */
+ if (count < real->segment_char_offset / 4)
+ p = g_utf8_offset_to_pointer (real->segment->body.chars + real->segment_byte_offset,
+ -count);
+ else
+ p = g_utf8_offset_to_pointer (real->segment->body.chars,
+ real->segment_char_offset - count);
new_byte_offset = p - real->segment->body.chars;
real->line_byte_offset -= (real->segment_byte_offset - new_byte_offset);
real->segment_byte_offset = new_byte_offset;
}
+ real->segment_char_offset -= count;
real->line_char_offset -= count;
adjust_char_index (real, 0 - count);