??? 07/08/11 13:19 Read: times |
#182817 - Depends on amounts of global data Responding to: ???'s previous message |
When you have char xx = <val> as a global variable, then the startup code will have to perform explicit assigns, or copy (possibly while decompressing) a block of data from the code space.
When you do char xx; xx = <val>, then the compiler will emit code for an assign at that specific place. Having many global variables, then the code loop that copies initial values will be small compared to the amount of variable data. Having few global variables means that the for loop that copies initial data from the code space will be larger than the code needed to perform explicit assigns. For a large program, a 1-byte global variable extra that needs an initial value will add 1 byte to your code (averaging less than 1 byte in case of the startup code using compression). A 1-byte global variable without assign with add zero bytes since the variable will be zeroed by the normal zeroing code. For small programs, you the cost of going from zero to one initialized global variable can be quite high. |
Topic | Author | Date |
Variable Initialisation | 01/01/70 00:00 | |
a question for (the) Raisonance (forum) | 01/01/70 00:00 | |
Depends on amounts of global data | 01/01/70 00:00 | |
Yes - Ask Raisonance! | 01/01/70 00:00 | |
Personal Preference Here | 01/01/70 00:00 | |
Another personal preference | 01/01/70 00:00 | |
My code based assignments are... | 01/01/70 00:00 | |
OO classes | 01/01/70 00:00 |