Repository navigation
perf(json): JsonToType<T> dispatch through non-template cores (-2 KB Teensy 4; closes #3247) - #3253
Conversation
… cores (closes #3247) #3247 / #3244 Tier 2E Phase 2. Introduces `fl/remote/rpc/json_dispatch.{h,cpp.hpp}` with four shared non-template helpers: - `json_convert_to_i64_core(val, out_i64)` - `json_convert_to_bool_core(val, out_bool)` - `json_convert_to_float_core(val, out_float)` - `json_convert_to_string_core(val, out_string)` Each replaces the per-(T × Visitor) `visit_fn` thunk explosion produced when `JsonToIntegerVisitor<T>` / `JsonToFloatVisitor<T>` / `JsonToBoolVisitor` / `JsonToStringVisitor` invoke `data.visit(visitor)`. The thin templated `JsonToType<T>::convert` wrappers in `json_to_type.h` now call the appropriate core (which does the 10-way alternative switch, the warning text formatting, and the conversion to the canonical i64/bool/float/string output) and then apply per-T narrowing + overflow detection. `FL_NO_INLINE` on the cores is load-bearing under LTO -- without it the compiler folds the body back at each call site, defeating dedup. ## Verification LPC845-BRK / AutoResearch (Low-memory): flash 47,128 B -> 47,020 B (-108 B) Teensy 4.0 / AutoResearch (Large-memory): flash 348,160 B -> 346,112 B (-2,048 B) The Low-memory win is modest because PR #3226 (#3224 Tier 1A) already gated most float / per-T visitor paths to setError() bodies; the linker had already DCE'd most of what this refactor would have shared. The Large-memory win matches the audit's predicted ~2 KB. ## Compatibility The visitor structs in `json_visitors.h` remain intact (not removed) for backward source compat. No public API change; behavior preserved (same warning text format, same error wording). Existing host tests in `tests/test_json*.cpp` and `tests/fl/remote/rpc.cpp` pass unchanged. Refs #3244, #3247
|
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 (4)
📝 WalkthroughWalkthroughIntroduces four ChangesNon-template JSON dispatch layer
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 #3247 (#3244 Tier 2E Phase 2).
Introduces non-template json_convert_to__core helpers, routes JsonToType::convert through them.
Verification
LPC845 win is modest because #3226 already gated most visitor paths to setError bodies on Low-memory; the Teensy 4 win matches the audit's predicted ~2 KB.
Refs #3244, #3247.
Summary by CodeRabbit