Declaring too many local variable in a function would affect the performance?
-
Hi, If i declare too many local variables(DWORD, CString, other data type) in a function, would that make my program slow.
Best Regards, Mushq Mushtaque Ahmed Nizamani Software Engineer Ultimus Pakistan "English is my second language; please excuse any grammatical or spelling mistakes"
-
Hi, If i declare too many local variables(DWORD, CString, other data type) in a function, would that make my program slow.
Best Regards, Mushq Mushtaque Ahmed Nizamani Software Engineer Ultimus Pakistan "English is my second language; please excuse any grammatical or spelling mistakes"
Depends on what is it doing in the constructor codes of the data type. Primitive data type should be harmless or at least not noticeable. If you running out of memory, it would also slow down your program because of resort to virtual memory. (It will slow or crash even for whatever you do I think anyway)
Sonork 100.41263:Anthony_Yio
-
Hi, If i declare too many local variables(DWORD, CString, other data type) in a function, would that make my program slow.
Best Regards, Mushq Mushtaque Ahmed Nizamani Software Engineer Ultimus Pakistan "English is my second language; please excuse any grammatical or spelling mistakes"
Depends on the variable and how it is being used. For example, creating a
DWORD
and adding to it in a loop is has significantly different performance implications than adding to aCString
in the same loop. I believe it boils down more to not how many variables you have, but how you are using them. Variables that manage resources for you (likeCString
) are easy to use incorrectly (or at least inefficiently). Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles -
Hi, If i declare too many local variables(DWORD, CString, other data type) in a function, would that make my program slow.
Best Regards, Mushq Mushtaque Ahmed Nizamani Software Engineer Ultimus Pakistan "English is my second language; please excuse any grammatical or spelling mistakes"
This Question is a typical case of "premature optimisation". Code your program. If its too slow determine why. A profiler would be helpful here. Fix *that* issue.
Failure is not an option - it's built right in.
-
Hi, If i declare too many local variables(DWORD, CString, other data type) in a function, would that make my program slow.
Best Regards, Mushq Mushtaque Ahmed Nizamani Software Engineer Ultimus Pakistan "English is my second language; please excuse any grammatical or spelling mistakes"
Technically, yes. Would you notice it? Probably not.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne