MinicraftPlus / minicraft-plus-revived

Minicraft+, an extension of Notch's original minicraft project, with tons more features.
GNU General Public License v3.0
456 stars 92 forks source link

Turn most multiplications and divisions of 16 to bit shifts #674

Closed BenCheung0422 closed 1 month ago

BenCheung0422 commented 2 months ago

Currently, many operations on the conversions between tile coordinates and pixel/entity coordinates are done by multiplication and division operators. For both readability and performance, they are mostly converted to bit shifts of 4. A tile consists of 16 units (exactly 4 bits), so using bitwise operators might be more suitable. In terms of performance, this only makes some micro-optimizations. More info: https://stackoverflow.com/q/1168451