refactor(core): inline isFactory within getNodeInjectable#59824
refactor(core): inline isFactory within getNodeInjectable#59824arturovt wants to merge 1 commit intoangular:mainfrom
isFactory within getNodeInjectable#59824Conversation
|
Esbuild should theoritically inline the function. Maybe if we just move it to the same file this could be achieved ? Edit: just checked, it doesn't. |
3ae2aae to
18de242
Compare
|
The |
|
OOC, why not inline in both cases? The condition seems self explanatory. Are we improving readability that much by wrapping it in a function call? |
|
@pkozlowski-opensource can you reopen the PR (I can’t do this), I will rebase and update another condition? |
18de242 to
a459aa4
Compare
This commit inlines the `isFactory` function body directly within `getNodeInjectable` because it is only used once. ESBuild does not inline its body within the function, which can be observed when running the build with `NG_BUILD_MANGLE=0`. The results after inlining are as follows: ``` getNodeInjectable x 70,397,377 ops/sec ±3.88% (52 runs sampled) getNodeInjectable_inlined x 77,834,432 ops/sec ±3.13% (60 runs sampled) ```
a459aa4 to
f7bf09e
Compare
|
This PR was merged into the repository by commit 1124b8f. The changes were merged into the following branches: main, 19.2.x |
This commit inlines the `isFactory` function body directly within `getNodeInjectable` because it is only used once. ESBuild does not inline its body within the function, which can be observed when running the build with `NG_BUILD_MANGLE=0`. The results after inlining are as follows: ``` getNodeInjectable x 70,397,377 ops/sec ±3.88% (52 runs sampled) getNodeInjectable_inlined x 77,834,432 ops/sec ±3.13% (60 runs sampled) ``` PR Close #59824
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This commit inlines the
isFactoryfunction body directly withingetNodeInjectablebecause it is only used once. ESBuild does not inline its body within the function, which can be observed when running the build withNG_BUILD_MANGLE=0. The results after inlining are as follows:Since
isFactoryis passed with different argument shapes, it never gets optimized.The function is also used only once, so there's no reason to keep it separate, because in minified code it's
function n(n){return n instanceof NodeInjectorFactory}.