Optimization of inlined values
I have the following inline method and call it several times in other
methods. Will the vc and gcc compilers with O2 optimization be able to
notice the value is fixed in the calling methods and evaluated it only
once? -- Indeed indexAndFlag is not changed inside those methods. -- Or,
maybe for thread-safety, it will be evaluated per each call?
unsigned int indexAndFlag;
...
inline Index* index() const
{
return (Index*)(indexAndFlag & ~1);
}
The code is only for protected mode x86 32/64bit architecture, so I hope,
I can assume sizeof(unsigned int) == sizeof(Index*). If not, please
correct me.
No comments:
Post a Comment