开发者

Same nested selection

开发者 https://www.devze.com 2023-01-19 00:23 出处:网络
Is there any performance difference between: size.width += this->font->chars[*ch].advance + this->font->chars[*ch].offset.x;

Is there any performance difference between:

size.width += this->font->chars[*ch].advance + this->font->chars[*ch].offset.x;

and

char_data *chars开发者_运维问答 = this->font->chars;
while(...) {
   size.width += chars[*ch].advance + chars[*ch].offset.x;
}

In first example are always read vars( this->font, font->chars ) within loop, or they are cached?


That would depend on your compiler and optimization settings. At the most basic level, the first one will be slower because you're doing extra dereferencing and access operations. But in reality, the optimizer can identify these repetitions and eliminate them.

To definitively answer this, you should run a test and compare the two to see if there is a statistically significant difference in running times.

0

精彩评论

暂无评论...
验证码 换一张
取 消