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)
This commit is contained in:
Matthias Clasen 2005-12-12 19:16:00 +00:00 committed by Matthias Clasen
parent dd3a8cd122
commit 104772f87a
4 changed files with 22 additions and 7 deletions

View File

@ -1,5 +1,9 @@
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)
* gtk/gtkicontheme.c (ensure_valid_themes): Only broadcast
_GTK_LOAD_ICONTHEMES if we detect a real theme change, not
upon initial theme load. (#323876, Peter Lund)

View File

@ -1,5 +1,9 @@
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)
* gtk/gtkicontheme.c (ensure_valid_themes): Only broadcast
_GTK_LOAD_ICONTHEMES if we detect a real theme change, not
upon initial theme load. (#323876, Peter Lund)

View File

@ -4146,6 +4146,11 @@ _gtk_text_line_char_to_byte_offsets (GtkTextLine *line,
{
const char *p;
/* 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;

View File

@ -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;
/* 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);
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);