Y
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
ok123456
1043 days ago
Compiler will do these strength reduction optimizations if they're applicable.
link
planede
1043 days ago
That's an optimization you can rely on, yes.
link
Chabsff
1043 days ago
Yeah, these are trivial optimizations.
link