On Mon, 05 Dec 2011 at 19:45:39 +0100, Markus Elfring wrote:
> > type = g_variant_get_type (gv);
>
> How do you think about the following instructions?
>
> GVariant* contained = g_variant_get_child_value (value, 0);
> type = g_variant_get_type (contained);
What is the type of "value"? If it's a "maybe" type like "m(xy)", then
this will only work correctly if "contained" is non-NULL. It'll produce
undefined behaviour (i.e. probably crash) if "contained" is NULL
If you want a function that, given a GVariant of type "m(xy)",
will return "(xy)", then I think Ryan already provided one, but
here is another:
const GVariantType *vt = g_variant_get_type (value);
/* you might want to assert that g_variant_type_is_maybe (vt) here */
return g_variant_type_element (vt);
> Is it possible to determine the child data type without retrieving
> the complete value?
See above.
> Would it be useful to optimise this approach?
I doubt it. The usual answer to "should we optimise $THING?" applies:
if you don't have profiling data that indicates that $THING is a bottleneck,
then no, optimising $THING isn't useful.
S
_______________________________________________
gtk-devel-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-devel-list