text: Optimize away 0-change insertions and deletions

We can short-circuit insert and delete calls that are
not causing any change.
This commit is contained in:
Matthias Clasen 2021-03-04 14:14:09 -05:00
parent 447203ce52
commit ccae0e1732

View File

@ -3309,6 +3309,9 @@ gtk_text_insert_text (GtkText *self,
int n_inserted;
int n_chars;
if (length == 0)
return;
n_chars = g_utf8_strlen (text, length);
/*
@ -3338,6 +3341,9 @@ gtk_text_delete_text (GtkText *self,
{
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
if (start_pos == end_pos)
return;
begin_change (self);
gtk_entry_buffer_delete_text (get_buffer (self), start_pos, end_pos - start_pos);