Skip to content

gvariant: Avoid malloc/free in valid_format_string()

Any extremely common use-case of valid_format_string() is validation when using GVariantBuilder. The optimal-case there is that there is no programming error and thus the fast path should match.

This creates a fast path for that case without substantial change to the GVariant type-checking case by checking for a non-NULL GVariant. It then proceeds to hoist the actual scan directly without type allocation.

Locally this single change reduces wallclock time in a single-threaded benchmark using GVariantBuilder by 17%.

Merge request reports