Repository navigation
perf(json): SizeVisitor + IsArrayVisitor → direct tag checks (-416 B LPC845; #3235 Tier 2E) - #3241
Conversation
…ks (#3235 Tier 2E Phase 1) Removes `SizeVisitor` and `IsArrayVisitor` -- two `data.visit(visitor)` patterns that each forced the variant to emit per-(T × Visitor) `visit_fn` thunks for all 10 `json_value::variant_t` alternatives (`nullptr_t`, `bool`, `i64`, `float`, `fl::string`, `json_array`, `json_object`, `vector<i16>`, `vector<u8>`, `vector<float>`). `json::is_array()` now inlines as 4 `data.is<T>()` tag checks; `json:: size()` inlines as 5 `data.ptr<T>()` tag-and-extract checks. Behavior preserved; the visitor structs themselves and their per-T thunk instantiations are gone. This is Phase 1 of the Tier 2E plan (validates the tag-table-lookup approach for visitors with simple result extraction). Phase 2 -- the `json_convert_to_<int/bool/float/string>_core` non-template helpers that collapse the heavier conversion visitors -- remains as a follow- on once the codebase has a sketch big enough to exercise the conversion path leverage. ## Verification (LPC845 / AutoResearch) flash 47,544 B -> 47,128 B (-416 B saved) RAM 9,984 B -> 9,984 B (unchanged) Predicted ~250 B; actual -416 B. The extra savings come from downstream DCE -- with no `visit_fn<T, SizeVisitor>` / `visit_fn<T, IsArrayVisitor>` references, the variant doesn't anchor the corresponding alternative-T copies into the thunk tables for those visitor types. Refs #3235 Tier 2E (Phase 1)
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIn ChangesJSON Visitor Struct Removal
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #3235 Tier 2E (Phase 1).
Removes SizeVisitor and IsArrayVisitor -- two data.visit(visitor) patterns that each forced the variant to emit per-(T × Visitor) visit_fn thunks for all 10 json_value::variant_t alternatives.
Numbers (LPC845 / AutoResearch)
Before: 47,544 B flash
After: 47,128 B flash (-416 B, RAM unchanged)
Predicted ~250 B; actual -416 B (downstream DCE from removing the visitor anchors gives extra savings).
Phase 2 of Tier 2E (the json_convert_to_<int/bool/float/string>_core helpers that collapse the heavier conversion visitors) deferred to a follow-on once a sketch big enough to exercise the conversion-path leverage lands.
Refs #3235 (Tier 2E)
Summary by CodeRabbit