Skip to content

2.11.0 — Zero-parse macro codegen + benchmarking

Choose a tag to compare

@sorunokoe sorunokoe released this 06 Aug 14:22
· 7 commits to main since this release

Performance

@Mapper's generated builder init and nested Builder enum are now built entirely out of typed SwiftSyntax nodes instead of interpolated Swift-source strings fed through DeclSyntax(stringLiteral:). Previously, expanding @Mapper forced the compiler to re-parse that generated text on every single expansion, with cost scaling with each mapped type's field count and type complexity. That re-parsing is now gone entirely — no text is generated or re-parsed at macro-expansion time.

Generated output is byte-for-byte unchanged: verified against the existing 996-line exact-expansion-string test suite (MapperMacroExpansionTests.swift) with zero test changes needed. No breaking changes.

Incidentally fixes a pre-existing MemberMacro deprecation warning encountered while touching this code.

Benchmarking

  • New dev-only Bench executable target (swift run -c release Bench) measures the @Mapper-generated builder initializer against a hand-written initializer and a plain memberwise initializer, confirming the builder stays a genuinely zero-cost runtime abstraction.
  • New docs/BENCHMARKING.md explains both of SwiftMapper's performance dimensions — runtime (zero-cost, measured) and compile time (no re-parsing, the dimension that actually scales with project size) — and how to reproduce/track them yourself.
  • README gets a short new Performance section linking to the doc.

Upgrading

No source changes required — this is a drop-in upgrade.