Skip to content

[perf] Speed up array_map/array_reduce closure param rules with cheap Closure arg bail before reflection - #8657

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-array-closure-param-reflection
Oct 15, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-array-closure-param-reflection

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Performance refactor of AddClosureParamTypeForArrayMapRector and AddClosureParamTypeForArrayReduceRector. No behavior change - all fixtures pass unchanged.

Both rules resolved the function reflection via resolveFunctionLikeReflectionFromCall() before checking that the closure argument is actually a Closure node. That reflection resolution was paid even for the common cases where the callback is a string callable or an arrow function, which can never match.

The cheap structural guard (closure arg present and is a Closure) is now hoisted above the reflection call. Both conditions are required anyway, so reordering is safe; reflection is only resolved once the closure arg is confirmed.

… with cheap Closure arg bail before reflection
@TomasVotruba TomasVotruba changed the title [TypeDeclaration] Speed up array_map/array_reduce closure param rules with cheap Closure arg bail before reflection [perf] Speed up array_map/array_reduce closure param rules with cheap Closure arg bail before reflection Oct 15, 2026
@TomasVotruba
TomasVotruba enabled auto-merge (squash) October 15, 2026 10:47
@TomasVotruba
TomasVotruba disabled auto-merge October 15, 2026 10:47
@TomasVotruba
TomasVotruba merged commit 2b94c94 into main Oct 15, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-array-closure-param-reflection branch October 15, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant