Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Which will be faster [C]

Name: Anonymous 2009-05-08 17:12

Bitfields (struct s { unsigned char w:1, x:1, y:2, z:4; };)
or bit operations (#define get_y(s) ((s >> 4) & 3))?

Yes, I'm a premature optimizer.

Name: Anonymous 2009-05-09 11:59

Bitfields are usually accessed using simple and/test/sh*/jcc operations(for x86*). You are using a 'shr' and 'and', either way it'll be very fast, but if you want, examing the compiled code and  get the intel processor manuals to decide which will be slightly faster than the other for the specific compiler(and the used settings) and target architecture.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List