Comment

Comment by greggman3

I like function tables. I think they are cleaner than switch statements

But, (maybe this is an invalid test), checking today my results suggest a switch is faster than a function table in 2022? At least at a base level. Maybe the more complicated the code for each case gets the less likely it is to get optimized.... which is true in general? large code blocks are less likely to get optimized and a switch is considered one large code block.

https://jsbenchit.org/?src=5c1e5bcf62448b6d1750b12893b0f0a1

parent greggman3 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton