变量名称的长度是否影响已编译的可执行文件? [英] Length of Variable Names Affect Compiled Executable?
问题描述
我的C变量名称的长度是否在性能方面对我的最终可执行程序有什么影响?我的意思是,一旦编译等,这两者之间是否有任何
的差异:
number = 3;
n = 3;
我知道它为变量本身留出了存储空间;如果变量名称更长,它还会使用
更多的存储吗?我意识到这可能会花费很多很长的变量名来产生任何影响,如果是这样的话,但我只是好奇,如果有人知道的话,我只是好奇...
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...
推荐答案
John写道:
John wrote:
我的C变量名称的长度是否有任何影响,性能-wise,
我的最终可执行程序?我的意思是,一旦编译等,这两者之间是否存在任何
的差异:
number = 3;
n = 3;
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;
标准没有说。
通常编译的代码是相同的。可以想象一个C
解释器需要更长的时间。
-
Thad
The Standard doesn''t say.
Normally compiled code will be the same. It is conceivable for a C
intepreter to take longer.
--
Thad
在文章< 45 *********************** @ auth.newsreader.octanew s.com>,
Thad Smith< Th ******* @ acm.orgwrote:
In article <45***********************@auth.newsreader.octanew s.com>,
Thad Smith <Th*******@acm.orgwrote:
> John写道:
>John wrote:
>在我的最终可执行程序中,我的C变量名称的长度对性能有影响吗?我的意思是,一旦编译等,这两者之间是否有任何区别:
数= 3;
n = 3;
>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;
>标准没有说。
>The Standard doesn''t say.
>正常编译的代码将是相同的。可以想象一个C / /解释器需要更长的时间。
>Normally compiled code will be the same. It is conceivable for a C
intepreter to take longer.
-potentially-可执行文件中可能有调试信息
记录原始变量名称;更大的变量名称可能会导致更大的调试部分;取决于操作系统的详细信息,
- 可能会导致稍大的启动时间(例如因为更大的文件被解析为链接和加载。)但可能
与影响
可执行文件大小的其他因素相比,任何此类效果都是微不足道的,例如代码量或优化
水平。
-
那时候我很年轻,但我也很朦胧。
- Christopher Priest >
John写道:
John wrote:
我的C变量名称的长度是否有任何影响性能方面,我的最终可执行程序是什么?我的意思是,一旦编译等,这两者之间是否有任何
的差异:
number = 3;
n = 3;
我知道它为变量本身留出了存储空间;如果变量名称更长,它还会使用
更多的存储吗?我意识到这可能会花费很多很长的变量名来产生任何影响,如果是这样的话,但是我只是很好奇,如果有人知道的话......
... b
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...
如果我们将C中的变量名与汇编语言进行比较,我们可以看到
如下:
在C中:
int number = 3;
int n;
n = number;
在asm中: (在进入
程序之前,ebp指向堆栈顶部。)
mov dword ptr [ebp-4],3
mov eax,dword ptr [ebp-4]
mov dword ptr [ebp-8],eax
C编译器持有一个表来存储变量名,但是在编译成汇编语言的
之后,该表将被删除。
在同一个问题中:
我们可以写在这样的汇编语言中:
在asm:
..data
数字dw 3
n dw?< br $> b $ b ....
..代码
....
mov ax,number
mov n,ax
....
同样的问题是:这两个之间有什么区别
变量名?
在遵守操作码后,它可以像这样执行:
....
A10000(mov ax,[ 0000])
A30200(mov [0002],ax)
....
所以,桌子由汇编编译器将被编译为操作码后销毁。
If we compare variable names in C with in assemble language,we can see
as follows:
In C:
int number = 3;
int n;
n=number;
In asm: (ebp point to the top of stack before going into the
procedure.)
mov dword ptr [ebp-4],3
mov eax,dword ptr [ebp-4]
mov dword ptr [ebp-8],eax
The C compiler hold a table to storage the variable names,but after
compiled to assemble language,the table will be distroyed.
In a same question:
We can write in assemble language like this:
In asm:
..data
number dw 3
n dw ?
....
..code
....
mov ax,number
mov n,ax
....
the same question is :is there any difference between these two
variable names?
After it complied to opcode,it may be executed like this:
....
A10000 ( mov ax,[0000])
A30200 ( mov [0002],ax)
....
So,the table holded by assemble compiler will be destroyed after it
compiled to opcode.
这篇关于变量名称的长度是否影响已编译的可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!