Compare commits

...

1 Commits

Author SHA1 Message Date
Christian Hergert
def05ef87c linedisplaycache: special case left-most binary search
If we have a y index of 0, we always want to look at the left-most
position instead of wasting time on a binary search for edges. This is an
extremely common case when loading or syntax highlighting a buffer such
as from GtkSourceView.
2020-08-07 11:45:28 -07:00

View File

@@ -596,6 +596,18 @@ find_iter_at_at_y (GtkTextLineDisplayCache *cache,
g_assert (!g_sequence_iter_is_end (left));
g_assert (!g_sequence_iter_is_end (right));
/* One of the most common cases is y==0, so special case it. */
if (y == 0)
{
GtkTextLineDisplay *display = g_sequence_get (left);
g_assert (display != NULL);
g_assert (display->line != NULL);
if (_gtk_text_btree_find_line_top (btree, display->line, layout) <= 0)
return left;
}
for (;;)
{
GtkTextLineDisplay *display;