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.
This commit is contained in:
Matthias Clasen 2015-09-10 18:48:29 -04:00
parent 0957ba5220
commit c86f0b1b23

View File

@ -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++)