summaryrefslogtreecommitdiff
path: root/gtk/gtkallocatedbitmask.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-09-10 18:48:29 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-09-12 11:24:37 -0400
commitc86f0b1b237bf8ccc47a5a5399a8acc55e0eb1fd (patch)
tree5a72d9b1d8c54b9d3d0ccae4bafdccd430fea59c /gtk/gtkallocatedbitmask.c
parent0957ba522008bc08631ee209b4dae8d7c5a7dce0 (diff)
downloadgtk+-c86f0b1b237bf8ccc47a5a5399a8acc55e0eb1fd.tar.gz
bitmask: Optimize no-op resizes
Statistics for the gtk3-demo listbox example show that the vast majority of calls to _gtk_allocated_bitmask_resize go from a size of 2 to 2. Don't needlessly call realloc() in this case.
Diffstat (limited to 'gtk/gtkallocatedbitmask.c')
-rw-r--r--gtk/gtkallocatedbitmask.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/gtk/gtkallocatedbitmask.c b/gtk/gtkallocatedbitmask.c
index 567b86cb91..0950d4362d 100644
--- a/gtk/gtkallocatedbitmask.c
+++ b/gtk/gtkallocatedbitmask.c
@@ -52,6 +52,9 @@ gtk_allocated_bitmask_resize (GtkBitmask *mask,
{
gsize i;
+ if (size == mask->len)
+ return mask;
+
mask = g_realloc (mask, sizeof (GtkBitmask) + sizeof(VALUE_TYPE) * (size - 1));
for (i = mask->len; i < size; i++)