73. Flip<T> / flip_action in std.lazy, combinator devirtualization, and LazyTreap fast path (2026-11-21)
- Add
Flip<T>(Flip.of) andflip_action<T, M>(m)tostd.lazy. Encapsulates the paired-complement range-toggle pattern ((now, flipped)withBoolXOR tag) for any monoidmwith zero compiler privilege. Adopted byproto/ports/ecnerwala/cf2152g.cp(387 -> 280 tokens, 1.27x of dream; 35,469 -> 30,720 B emitted). Reverse: removeFlipandflip_actionfromstdlib/lazy.cpand restore the hand-rolledActionincf2152g.cp. - Treat closures whose captures are only used as
StaticDirectcallees as captureless incpl-codegen. Incrates/cpl-codegen/src/devirt.rs, a closure that captures aMonoidorActionsolely to invoke itsStaticDirectop/apply/composefield has zero live captures in emitted C++, so it lowers to a top-levelstatic auto cpl_fnN(emitted in dependency order inemit.rs) with zerostd::function. Gives 0std::functiononflip_action(cf2152g: 8 static direct, 0 dynamic) and any user-writtenMonoid/Actioncombinator. Reverse: restorecaptures.is_empty()indevirt.rs. - Avoid sibling cache misses and tagless pushdown calls in
LazyTreap.ins/split_val. Incrementnodes[i].szdirectly on descent ininsand guardpush_tagwithif let f = nodes[i].tag:inins/split_val, bringingbench/ranges/lazy_treapfrom111.9 ms(1.34x) down to85.8 msvs81.1 msmatched C++17 (1.06x). Reverse: restoredown/pullcalls instdlib/lazy.cp.