/pkg/bitmap/bitmap.go : Replace multiplication and division for power of two's numbers with bit manipulation
vax-r opened this issue · comments
Description
Description
In the file of /pkg/bitmap/bitmap.go
exists some instructions related to multiplication and division, while the multiplier or divisor is some power of two's number. We should replace them with bitwise operation so we can provide better capability for different CPU platform , some of which might be lack of division instructions on the CPU.
Is this feature related to a specific bug?
No response
Do you have a specific solution in mind?
I suggest we can replace all the instructions mentioned above with bitwise operation such as the following
bSize := (size + 63) / 64
We can change the above instruction to
bSize := (size + 63) >> 6
If you guys think it's possible, I can create a corresponding PR to fix it.
I think it's very likely that Go will compile <value> / 64
to a right shift instruction. If you're seeing assembly on an architecture that doesn't do this or has some other issue, please let us know.