Originally Posted by
Epy
I just don't know enough about computers to judge the time it takes to retrieve a value from memory that may or may not be a part of the local stack vs. casting another variable whenever needed.
In any case, it is probably trivial. However, you could approach it like this:
Code:
for (i=0; i<strlen(whatever); i++)
That's a bad idea because now strlen is called everytime, so it is much better to use an extra variable assignment (presuming the strlen isn't going to change):
Code:
int x = strlen(whatever);
for (i=0; i<x; i++)
In other words, if you have a block or a loop or a function that is getting called hundreds of times with a cast in it that could be replaced with a single temp variable, then maybe it is worth it.
But pretty sure most casts are way less expensive than strlen() calls...I don't think you need to sweat about it too much.