Merge branch 'array-allocations' into 'master'

garray: Optimise over-allocations with g_array_insert_vals()

See merge request GNOME/glib!53
This commit is contained in:
Christoph Reiter 2018-06-07 08:06:15 +00:00
commit bb92a03d68

View File

@ -546,7 +546,10 @@ g_array_insert_vals (GArray *farray,
/* Is the index off the end of the array, and hence do we need to over-allocate
* and clear some elements? */
if (index_ >= array->len)
{
g_array_maybe_expand (array, index_ - array->len + len);
return g_array_append_vals (g_array_set_size (farray, index_), data, len);
}
g_array_maybe_expand (array, len);