mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-06 17:36:14 +01:00
Merge branch 'wip/chergert/gvariantbuilder-avoid-g_renew-for-known-children-length' into 'main'
glib/gvariant: avoid g_renew() for definite tuples See merge request GNOME/glib!4298
This commit is contained in:
commit
4596bd819d
@ -3760,6 +3760,7 @@ g_variant_builder_end (GVariantBuilder *builder)
|
||||
{
|
||||
GVariantType *my_type;
|
||||
GVariant *value;
|
||||
GVariant **children;
|
||||
|
||||
return_val_if_invalid_builder (builder, NULL);
|
||||
g_return_val_if_fail (GVSB(builder)->offset >= GVSB(builder)->min_items,
|
||||
@ -3788,10 +3789,14 @@ g_variant_builder_end (GVariantBuilder *builder)
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
children = GVSB(builder)->children;
|
||||
|
||||
/* shrink allocation to release extra space to allocator */
|
||||
if G_UNLIKELY (GVSB(builder)->offset < GVSB(builder)->allocated_children)
|
||||
children = g_renew (GVariant *, children, GVSB(builder)->offset);
|
||||
|
||||
value = g_variant_new_from_children (my_type,
|
||||
g_renew (GVariant *,
|
||||
GVSB(builder)->children,
|
||||
GVSB(builder)->offset),
|
||||
children,
|
||||
GVSB(builder)->offset,
|
||||
GVSB(builder)->trusted);
|
||||
GVSB(builder)->children = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user