speed of passing variables
I read somewhere that all the CPU deals with is 32bit data so optimisations should take this in to account. Say, when passing data to a low level math function should I pass in a signed long rather than an int? (when storage space doesn''t matter)
Does the compiler do this for you?
Chris Brodie
Don''t even worry about it. For one thing, there''s no gurantee regarding the size of various data types, so that unsigned long may or may not be 32 bits. Also, the compiler will optimize all sorts of things for you... better to write code that''s meaningful and leave the low-level optimizations to the compiler.
If you are using a 32bit environment, your integers are 32bits (the same size as a long.)
The (short) reason why 16bit (WORD) values are unfavorable is because they require a prefix byte in the opcode which isn''t pairable in the pentium execution pipes. Meaning: It will add a cycle or two. Nothing to sweat unless ALL variables are shorts. There are no such penalties for 32bit (DWORDS) or 8bit (BYTE) values.
.travois.
The (short) reason why 16bit (WORD) values are unfavorable is because they require a prefix byte in the opcode which isn''t pairable in the pentium execution pipes. Meaning: It will add a cycle or two. Nothing to sweat unless ALL variables are shorts. There are no such penalties for 32bit (DWORDS) or 8bit (BYTE) values.
.travois.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement