Skip to content

fix(unity-build): re-sort fl/stl/_build.cpp.hpp includes alphabetically - #3243

Merged
zackees merged 2 commits into
masterfrom
fix/unity-build-include-order-3235
Jun 18, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/unity-build-include-order-3235

Conversation

@zackees

@zackees zackees commented Jun 18, 2026 •

Copy link
Copy Markdown
Member

Follow-up to PR #3240 (#3235 Tier 1C). UnityBuildChecker flagged unordered_map_basic.cpp.hpp as out of alphabetical order. Moved to correct slot after type_traits.cpp.hpp. No behavior change.

Refs #3235

Summary by CodeRabbit

  • Refactor
    • Improved internal performance optimizations for JSON type handling and build configuration.

Note: This release contains no user-visible changes or new features.

zackees added 2 commits June 18, 2026 15:23
…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)
PR #3240 (Tier 1C) added `unordered_map_basic.cpp.hpp` between
`fstream` and `ieee754_string`, which the UnityBuildChecker flagged as
out of alphabetical order ('u' > 'i'). Move it to its correct slot
after `type_traits.cpp.hpp`. No behavior change.
@zackees
zackees merged commit 1bb6a08 into master Jun 18, 2026
10 checks passed
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a2de012a-eac4-48a2-8855-1533b365d780

📥 Commits

Reviewing files that changed from the base of the PR and between e1c0908 and 330f1ce.

📒 Files selected for processing (2)
  • src/fl/stl/_build.cpp.hpp
  • src/fl/stl/json/types.h

📝 Walkthrough

Walkthrough

json_value::is_array() and json_value::size() are rewritten to use direct fl::variant tag checks (data.is<T>() / data.ptr<T>()) instead of visitor structs, removing SizeVisitor entirely. The unity-build file reorders unordered_map_basic.cpp.hpp to follow type_traits.cpp.hpp.

Changes

JSON visitor removal and build order fix

Layer / File(s) Summary
Remove SizeVisitor; rewrite is_array() and size() with direct tag checks
src/fl/stl/json/types.h
SizeVisitor struct is deleted. json_value::is_array() now uses data.is<T>() for json_array and packed vector types. json_value::size() uses data.ptr<T>() to return the matching container's .size(), replacing all prior data.visit(...) calls.
Reorder unordered_map_basic include after type_traits in unity build
src/fl/stl/_build.cpp.hpp
fl/stl/unordered_map_basic.cpp.hpp is moved from the earlier current-directory includes block to after fl/stl/type_traits.cpp.hpp, changing the unity-build compilation order.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop hop, the visitors are gone,
No struct to build, no visit to spawn.
A pointer tag, a simple .is<T>,
The size is found so efficiently!
And build order nudged — just one line swap,
This rabbit approves, then takes a nap. 🌙

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/unity-build-include-order-3235

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 18, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 18, 2026
@zackees
zackees deleted the fix/unity-build-include-order-3235 branch August 21, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant