Comment

Comment by mkmccjr

Aha, I think I better understand your point: since the generated bytecode includes a cast, my explanation about the optimization is too simplistic.

I haven't actually inspected the emitted bytecode, so I was only reasoning from the observed speedup.

Your point about branch prediction is really interesting; it would explain how the cast becomes almost free once the type is stable in the hot path.

I'm learning a lot from this thread -- thank you for pushing on the details!

parent mkmccjr 8 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton