[v9] fix: prefer named functions, for loops in hot paths #2540
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following the discussion here https://discord.com/channels/740090768164651008/740093168770613279/1023859404111613962
I went to add a name function to remove this anonymous function from the performance tool report
I also thought that we could replace the forEach with for loops where applicable.
With the for loop there isn't a need to use a named function at all in the end.
So I went through the files and replaced the forEach loop that looked safe to replace.
I'm expecting a gain of 1µs per frame with that
The perf gain is probably neglectable but it removes some noise from the performance and also use less memory for one of them that was creating a new array on each call ( cancelPointer )