Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
jezze
· 3y ago · 0 comments
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?
Comments
[–]
ok123456
3y ago
Compiler will do these strength reduction optimizations if they're applicable.
[–]
planede
3y ago
That's an optimization you can rely on, yes.
[–]
Chabsff
3y ago
Yeah, these are trivial optimizations.