Commit 112bf468 authored by Christian Hergert's avatar Christian Hergert

view: short-circuit when painting background marks

Often times we do not have any source marks. We can use that information
to avoid walking the buffer during our draw_layer operations.

This is a minor performance improvement in the common case.
parent ff33e68b
...@@ -80,6 +80,9 @@ void _gtk_source_buffer_restore_selection (GtkSourceBuffer *buffer); ...@@ -80,6 +80,9 @@ void _gtk_source_buffer_restore_selection (GtkSourceBuffer *buffer);
GTK_SOURCE_INTERNAL GTK_SOURCE_INTERNAL
gboolean _gtk_source_buffer_is_undo_redo_enabled (GtkSourceBuffer *buffer); gboolean _gtk_source_buffer_is_undo_redo_enabled (GtkSourceBuffer *buffer);
GTK_SOURCE_INTERNAL
gboolean _gtk_source_buffer_has_source_marks (GtkSourceBuffer *buffer);
G_END_DECLS G_END_DECLS
#endif /* GTK_SOURCE_BUFFER_PRIVATE_H */ #endif /* GTK_SOURCE_BUFFER_PRIVATE_H */
...@@ -2325,6 +2325,19 @@ gtk_source_buffer_remove_source_marks (GtkSourceBuffer *buffer, ...@@ -2325,6 +2325,19 @@ gtk_source_buffer_remove_source_marks (GtkSourceBuffer *buffer,
g_slist_free (list); g_slist_free (list);
} }
gboolean
_gtk_source_buffer_has_source_marks (GtkSourceBuffer *buffer)
{
g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), FALSE);
if (buffer->priv->all_source_marks != NULL)
{
return !_gtk_source_marks_sequence_is_empty (buffer->priv->all_source_marks);
}
return FALSE;
}
static GtkTextTag * static GtkTextTag *
get_context_class_tag (GtkSourceBuffer *buffer, get_context_class_tag (GtkSourceBuffer *buffer,
const gchar *context_class) const gchar *context_class)
......
...@@ -2464,6 +2464,7 @@ gtk_source_view_paint_marks_background (GtkSourceView *view, ...@@ -2464,6 +2464,7 @@ gtk_source_view_paint_marks_background (GtkSourceView *view,
gint i; gint i;
if (view->priv->source_buffer == NULL || if (view->priv->source_buffer == NULL ||
!_gtk_source_buffer_has_source_marks (view->priv->source_buffer) ||
!gdk_cairo_get_clip_rectangle (cr, &clip)) !gdk_cairo_get_clip_rectangle (cr, &clip))
{ {
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment