jidder wrote: |
---|
It works as intended.
But it uses 99% cpu
Having to go through all the code again is a waste of time and resources. |
Thats why profilers exist. You don't have to go through the whole code, just the sections of the code that require optimization. Also, I'm not talking about efficient 'design' here, I'm talking about the little things that people insist on using that make their life harder, even though they would be more productive otherwise (like using C-strings rather than std::string, or making their own linked list instead of std::list). Efficient design is a completely different matter, however. It requires you planning your code and its structure to be inherently efficient, as well as being productive and preventing code duplication or dodgy workarounds.
jidder wrote: |
---|
Why not just use long long ints for everything incase you suddenly require huge numbers? |
You probably could, until you realize that for certain tasks you are never (as in, its not actually possible) are going to use those numbers. For most cases,
long
(or
size_t
) are perfectly sufficient. At any rate, only don't have integers that size unless you are certain you won't need it, or you know for sure that it would have a
noticable impact on your program (e.g. using an array of
unsigned long long
when you know that
unsigned char
is all thats needed). Otherwise, sure, do what you like. Just to make myself clear, I wasn't saying that the use of
unsigned char
in that situation was bad, just that there is no reason NOT to use
size_t
.