a question about code optimization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---------code-----------
vector<int> a;
/*do somthing*/
for(int i = 0; i<a.size(); i++) {
	/* do something*/
}
--------code end--------

my question is:
is it possible that the compiler will transform the code to this:

int __tmp = a.size();
for(int i = 0; i < __tmp; i++) {
	/*do something*/
}

i think it is impoossible,because in size() function, the programmer
can change some global variables, so the compiler could not do that.

if gcc can, could you tell me how?

i am sorry in advance because i am not familiar with the code optimization.
so i do not know how to search the gcc manual and gcc internal manual to find
answer.could anyone tell me how to find this in the manual?or at least give
some keywords?

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux