Skip to content

Minor optimizations to GtkSnapshot state stack

Alexander Larsson requested to merge alexl/gtk:snapshot-stack-optimize into master

I saw that pushing and pop:ing the state stack was taking quite some cpu time in the fishbowl demo. These are some minor optimizations that got it from like 4% to 2% in my tests (although getting exact measurements is tricky).

What it does is first of all, don't memset the new state each time, as these elements are rather large, as the max size of the union of per-node-type data is large even though most types don't use all that. (And anyway we initialize all elements that need to be initialized manually after pushing.)

Secondly, it tweaks the inlike markers a bit in gdkarrayimpl.c so that the internal functions (reserve/splice) get inlined into the callers in append/set_size. That way we propagate the constant arguments in the call sites. For example, if we call append() we always get a constant removed=0, added=1 which helps removing dead code.

Merge request reports