Skip to content

[Type-Erasure] json: outline visitor warning-string formatter (#3244 Tier 3I) #3251

Closed

Description

@zackees

Parent: #3244 (Phase 3 burn-down).

Goal

Outline the warning-string formatter currently inlined in every JSON conversion visitor (JsonToIntegerVisitor<T>, JsonToBoolVisitor, JsonToFloatVisitor<T>, JsonToStringVisitor). Each visitor today embeds a call to fl::to_string(value, 6) or fl::to_string(static_cast<i64>(mValue)) inside its warning emission path; this anchors basic_string formatter machinery even in builds where the warnings never fire at runtime.

Reproduction (baseline)

bash bloat lpc845brk --example AutoResearch --top 30
# Visitor operator() bodies emit ~120-250 B each due to inlined fl::to_string formatters.

Acceptance

  • PR introduces a single non-template fl::detail::format_warning_value(json_tag, const void* storage) helper that returns the warning string.
  • All four visitor families call the helper instead of inlining fl::to_string(...).
  • Measured savings on LPC845-BRK / AutoResearch: ≥ 500 B net flash drop. Audit predicted ~1-2 KB across all visitors.
  • Existing host tests pass unchanged.

Design reference

Audit observation from #3235:

"Each visitor today inlines a fl::to_string(value, 6) warning formatter that anchors basic_string machinery. Outline to a single format_warning_value(tag, storage) helper that only links if any visitor actually emits a warning at runtime."

The savings compound with Tier 2E Phase 2 (which moves the visitor bodies to a non-template core anyway).

Risk

Out of scope

  • Changing the warning wording itself.
  • Switching from in-memory format-string assembly to compile-time format tables (separate refactor; not worth the diff).

Refs #3244, #3235 (Tier 3I).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions