[gtk/wip/chergert/faster-comparison] textlayout: remove use of GtkTextIter in line comparison
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/faster-comparison] textlayout: remove use of GtkTextIter in line comparison
- Date: Wed, 4 Sep 2019 16:13:44 +0000 (UTC)
commit 7cea21043ea33ab7db5fa2cdfc8bd2834285dd04
Author: Christian Hergert <chergert redhat com>
Date: Wed Sep 4 09:12:54 2019 -0700
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.
gtk/gtktextlayout.c | 15 ++++++++++-----
1 file 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]