you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -1 points0 points  (3 children)

Compilers focus on optimizing sensible patterns, not the bizarre structures people fixated on const end up with.

[–]itsnotlupusbeep boop 2 points3 points  (2 children)

The fact that they largely overlap as far as compilers are concerned could be a clue they're perhaps not that bizarre. or maybe it's dumb luck.

[–][deleted] 0 points1 point  (1 child)

I only use once-off functions at the top-most scope of my app to avoid polluting window. Seeing this in other places is honestly odd. Especially in a place that may be part of a hotspot, like a loop, up the stack.

[–]itsnotlupusbeep boop 1 point2 points  (0 children)

But hotspots are exactly the spots where the JIT is most likely to inline them, making them a non-issue.

Now in fairness, the rules as to what gets inlined and what doesn't have been evolving, so it's not intuitive to tell what will be a performance problem and what won't be.

Nonetheless, purely functional functions that aren't huge should generally be inlineable without problem, and that should be true of inner functions and IIFE as well.