Re: bitwise operators

TL:DR - Don't optimise via bitfields, let the compiler and the computer do its job.

Sometimes bitfields are of use (i.e. simple powers of 2, simple if-this-then-that cases), but the vast majority of the time they make a simple task more complicated, the code becomes significantly harder to understand - and as such they are very prone to bite you in the ass.

If you want a book on bit-twiddling (and this is one I actually own), try:
http://www.hackersdelight.org/

I'd caution anyone thinking they can save a few cycles by raw bit manipulation that they may also cost themselves a few hours if not days or weeks later down the track figuring where their bit-twiddling didn't work as expected in corner-cases because they bypassed the normal checks-and-balances built into the programming language primitives they were working with.

Also, only ever optimise the core code than runs 95% of the time. If you can make something 1ms quicker and it runs 60 times per second then you're up 60ms * 60 minutes * 24 hours = 86,400ms = 1,440 seconds = 24 minutes per day. If you optimise something by 5000ms (5000 times more!) that runs once per day then you gain 5 seconds, and you probably spent at least a few hours 'optimising' it.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : r3dux via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : r3dux via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : kaigoku via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : r3dux via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : r3dux via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : pranam via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : pranam via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector

Reply via email to