GVariant: calculate size at construction
It's always possible to determine the serialised size of a GVariant
instance, even in the case that it is not yet serialised. This can be
done by calling g_variant_get_size() which will base its answer on the
size of each child (which must be recursively determined).
We must perform this process before we can allocate the buffer to
serialise a GVariant into (since we must know the size of the buffer).
This means that serialising a GVariant involves two steps that recurse
through the entire tree of values. We must take locks twice.
Simplify this by always determining the size when the instance is first
created, from the sizes of its children (which now will always be known
as well). We can do this without taking any locks because the
newly-created instance has never been exposed and because the size on
the children is now a constant that can be directly accessed without a
lock.
This is a reduction in complexity and will also be a performance
improvement in all cases where a GVariant is serialised. It will be a
slight performance hit in the case that we construct tree-form instances
and never serialise them.