Re: Length of Variable Names Affect Compiled Executable?
- From: Richard Heathfield <invalid@xxxxxxxxxxxxxxx>
- Date: Wed, 27 Sep 2006 06:52:44 +0000
John said:
Does the length of my C variable names have any affect, performance-wise,
on
my final executable program? I mean, once compiled, etc., is there any
difference between these two:
number = 3;
n = 3;
I know its setting aside storage for the variable itself; does it also use
up more storage if the variable name is longer? I realize it would
probably take quite a lot of long variable names to make any impact if so,
but I was just curious if anyone knew...
I have read the parallel replies with great interest and amusement. It's
amazing how much juice you can squeeze from C.
Nevertheless, *in general* the answer to your question is "no". Yes, various
people have drawn attention to various exceptions to that answer, which you
may wish to take into account. But in the general case, your implementation
will (or can be told to) discard all such information.
Thus, using b instead of CurrentBalance is an unnecessary "optimisation"
which will, in the general case, have no impact on performance. Write
clear, readable code using good algorithms and descriptive identifiers.
Worry about performance only in the extremely rare cases where good
algorithms don't deliver sufficient performance to meet your users' needs.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.
- References:
- Prev by Date: Re: Length of Variable Names Affect Compiled Executable?
- Next by Date: Re: Why pointers??
- Previous by thread: Re: Length of Variable Names Affect Compiled Executable?
- Next by thread: Re: Length of Variable Names Affect Compiled Executable?
- Index(es):
Relevant Pages
|