Design decisions

62. Containers Batch 2 and wave-12A perf lowerings (2026-11-21)

  1. Bitset<D> adopts Subset<D> parity (empty, full as @get, single, complement, set, plus of(xs: List<D>) for generators) while staying ordinary stdlib code. Reason: matches Subset<D> constructors/operations and accepts Bitset<V>.of(k for k in V if ...); direct for v in b stays a general core-lane iteration protocol (no Bitset compiler privilege). Reverse: revert the added methods in stdlib/bitset.cp.
  2. Bounded-domain Bitset<D> (D.K <= 4096 statically provable) reuses cpl::Row<U64, W> inline storage and cpl-codegen fuses (a & b & ...).len/.count/.is_empty into one zero-allocation popcount pass. Reason: eliminates O(n^3) heap allocations on cf1146h (2.82x -> 1.29x matched C++) without adding a new runtime container type. Reverse: remove the Bitset branch in cpl-codegen/src/scope.rs::rows and try_fused_bitset_op in expr.rs.
  3. sort(by: key) with a cheap pure key expression lowers to in-place std::stable_sort with an inlined comparator instead of cpl::sort_by's three auxiliary vectors. Reason: preserves stability and interpreter parity while eliminating O(n) temp allocations and index indirection (cf1284e: 1.63x -> 1.14x matched C++, -709 B emitted). Reverse: remove the is_cheap_pure_key branch in cpl-codegen/src/stmt.rs.