开发者

Same nested selection

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜