diff --git a/REVIEW.md b/REVIEW.md index 1c906e13e3..0623131f0f 100644 --- a/REVIEW.md +++ b/REVIEW.md @@ -453,6 +453,23 @@ if (!child->isHidden()) { The same applies to any logic that depends on a previous `show()`/`hide()` call: skip blocks, layout branches, opacity decisions, etc. +## Consolidate make_state calls into a single State struct + +Every `make_state` is a separate heap allocation. When a function needs multiple pieces of lambda-captured mutable state, define a local `struct State` with all fields and call `make_state()` once, then capture the resulting pointer everywhere. + +```cpp +// BAD - two allocations: +const auto shown = lifetime.make_state(false); +const auto count = lifetime.make_state(0); + +// GOOD - one allocation: +struct State { + bool shown = false; + int count = 0; +}; +const auto state = lifetime.make_state(); +``` + ## Static member functions use PascalCase Non-static member functions use camelCase (`startBatch`, `finalize`). Static member functions use PascalCase (`ShouldTrack`, `Parse`, `Create`), matching the convention for free functions.