summaryrefslogtreecommitdiff
path: root/gtk/gtktextiter.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/gtktextiter.c')
-rw-r--r--gtk/gtktextiter.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c
index 0a62df89b4..7a83d30a33 100644
--- a/gtk/gtktextiter.c
+++ b/gtk/gtktextiter.c
@@ -2391,19 +2391,14 @@ gtk_text_iter_backward_chars (GtkTextIter *iter, gint count)
if (real->line_byte_offset >= 0)
{
+ const char *p;
gint new_byte_offset;
gint i;
- new_byte_offset = 0;
- i = 0;
- while (i < real->segment_char_offset)
- {
- const char * start = real->segment->body.chars + new_byte_offset;
- new_byte_offset += g_utf8_next_char (start) - start;
-
- ++i;
- }
+ p = g_utf8_offset_to_pointer (real->segment->body.chars,
+ real->segment_char_offset);
+ 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;
}