Skip to content

v2.12.1: fix 2.12.0 build-time regression (short argOrDefault calls in invokers) - #58

Merged
gmpassos merged 1 commit into
masterfrom
perf/builder-invokers
Oct 15, 2026
Merged

gmpassos merged 1 commit into
masterfrom
perf/builder-invokers

Conversation

@gmpassos

@gmpassos gmpassos commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Problem

2.12.0's constructor invokers write each omittable argument inline as
identical(a[i], ConstructorReflection.absentArgument) ? default : a[i] as T.
dart_style is very slow on long argument lists of these: in a project with many large entity constructors, a clean build went from 6s (2.11.0) to 69s, 64s of it in formatting (its largest generated file alone: 41s), and its CI ensure_build test timed out at 120s.

Bisected to ef2fef1 (typed defaults in invokers).

Fix

  • ConstructorReflection.argOrDefault<T>(arg, defaultValue): the default when arg is absentArgument, else arg as T.
  • Generated invokers call it through __argOr$, a short alias declared in the generated file on first use (like the __RCD record aliases):
    invoker: (a) => Foo.named(a[0] as String, x: __argOr$<double>(a[1], 0)),
    The default is still typed in T's context (0.0 for double x = 0, a List<String> for const []).

Measured (that project's clean build, local)

building formatting
2.11.0 6s <1s
2.12.0 69s 64s
inline ConstructorReflection.argOrDefault<T> 37s 32s
this PR (__argOr$) 7s 1.6s

That project with this builder: dart analyze clean, its entity/module tests pass.

Tests

  • New argOrDefault unit test; build/generated-code tests updated to the new shape (the generated-code test still compiles the invokers under strict analysis and runs them).
  • Regenerated test/example .g.dart.
  • 562 pass locally. The two ReflectionInspector tests fail only when run from a git worktree under .claude/ (the inspector skips hidden dirs); they pass in the main checkout.

🤖 Generated with Claude Code

…2.12.0 build-time regression)

The inline `identical(a[i], ConstructorReflection.absentArgument) ? d : a[i] as T`
of each omittable invoker argument made dart_style very slow on large
constructors: in menu_ici_api, formatting went from ~1s to 64s and a full
build from 6s to 69s. Each argument is now `__argOr$<T>(a[i], d)`, a short
alias (declared on first use) of the new
`ConstructorReflection.argOrDefault<T>`; defaults are still typed in T's
context. Build back to 7s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.54%. Comparing base (242e245) to head (17d9912).

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #58   +/-   ##
=======================================
  Coverage   93.53%   93.54%           
=======================================
  Files          14       14           
  Lines        6532     6538    +6     
=======================================
+ Hits         6110     6116    +6     
  Misses        422      422           
Flag Coverage Δ
unittests 93.54% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmpassos
gmpassos merged commit 5e99421 into master Oct 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant