Our nullish coalescing operators are compiled into ternaries that perform unnecessary operations. We got a performance report which indicates that writing explicit ternaries could yield a performance increase. Whatever performance increase this would yield is sure to be slight, but since these are high-volume functions, these changes could still be worthwhile.
As you can see, the difference is negligible, but could the result be slightly different in Gameface? Either way, these changes shouldn't possible be able to make anything worse.
Alternatives
This would be a bigger task, but we could instead change the parameters for how we compile our code to begin with, to make a larger-scale change rather than micro-optimizations like in this PR. Whether that is worth the while, however, I cannot say, but the collateral risk would be higher.
Overview
Our nullish coalescing operators are compiled into ternaries that perform unnecessary operations. We got a performance report which indicates that writing explicit ternaries could yield a performance increase. Whatever performance increase this would yield is sure to be slight, but since these are high-volume functions, these changes could still be worthwhile.
Changes
I will use the
setupClassUpdate
as an example.Current implementation
... which is compiled into:
New implementation
... which is compiled into:
The difference is slight, but the key change is that this line:
... is simplified into this line:
Benchmarking
I benchmarked these changes using the
toggleRealisticClass
set of tests, using the same command as the CI does:main
First run
Second run
This branch
First run
Second run
As you can see, the difference is negligible, but could the result be slightly different in Gameface? Either way, these changes shouldn't possible be able to make anything worse.
Alternatives
This would be a bigger task, but we could instead change the parameters for how we compile our code to begin with, to make a larger-scale change rather than micro-optimizations like in this PR. Whether that is worth the while, however, I cannot say, but the collateral risk would be higher.