Hacker News new | ask | show | jobs
by jezze 1043 days ago
Wouldnt it be faster to do length & 1 instead of length % 2 and also length >> 1 instead of length / 2? But maybe the compiler does this behind the scenes?
3 comments

Compiler will do these strength reduction optimizations if they're applicable.
That's an optimization you can rely on, yes.
Yeah, these are trivial optimizations.