Re:Spending 3 months investigating a 7-year old bug and fixi...
by ladberg on Friday June 21, 2024 @03:23PM
(#40752764)
It wasn't `x % 16` it was `x % y` where x and y are 16-bit integers. A compiler would also have taken care of it if it were just a literal.
Re:Spending 3 months investigating a 7-year old bug and fixi...
by drewg123 on Friday June 21, 2024 @03:36PM
(#40752887)
Whoops.. I misread what he was doing.
Re:Spending 3 months investigating a 7-year old bug and fixi...
by xgkickt on Friday June 21, 2024 @08:43PM
(#40755264)
Reading the comments, that's kinda what they did, though they had to learn that first and only now realize they only needed one.
Re:Spending 3 months investigating a 7-year old bug and fixi...
by kevin_thibedeau on Friday June 21, 2024 @10:22PM
(#40755668)
Any top-tier C compiler will optimize modular division by a constant into a more efficient operation(s). It is better to keep the intent of the code clear rather than devolve it into increasingly obtuse bit-twiddling tricks the compiler can figure out on its own.
Eg, for positive integers, x % 16 == x & 15. That should be trivially cheap.