diff options
author | Christian Hergert <chergert@redhat.com> | 2019-09-04 09:12:54 -0700 |
---|---|---|
committer | Christian Hergert <chergert@redhat.com> | 2019-09-04 09:12:54 -0700 |
commit | 7cea21043ea33ab7db5fa2cdfc8bd2834285dd04 (patch) | |
tree | 799f69f581ff3f795eacb7994775ea12fb4b3361 /gtk/gtktextlayout.c | |
parent | cbdea09c92450e5c0a3676f899c6164d7e5a9e51 (diff) | |
download | gtk+-7cea21043ea33ab7db5fa2cdfc8bd2834285dd04.tar.gz |
textlayout: remove use of GtkTextIter in line comparison
We do not need to create a GtkTextIter to perform the comparison here as
that will require a number of validation steps that are extra work
compared to just discovering the GtkTextLine number directly.
Diffstat (limited to 'gtk/gtktextlayout.c')
-rw-r--r-- | gtk/gtktextlayout.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index 5e4b5975a3..fee6d59a4a 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -4197,11 +4197,16 @@ gtk_text_line_display_compare (const GtkTextLineDisplay *display1, const GtkTextLineDisplay *display2, GtkTextLayout *layout) { - GtkTextIter iter1; - GtkTextIter iter2; + gint line1; + gint line2; - gtk_text_layout_get_iter_at_line (layout, &iter1, display1->line, 0); - gtk_text_layout_get_iter_at_line (layout, &iter2, display2->line, 0); + line1 = _gtk_text_line_get_number (display1->line); + line2 = _gtk_text_line_get_number (display2->line); - return gtk_text_iter_compare (&iter1, &iter2); + if (line1 < line2) + return -1; + else if (line1 > line2) + return 1; + else + return 0; } |