What are the differences between using array offsets vs pointer incrementation?

后端 未结 11 1187
醉话见心
醉话见心 2021-02-06 13:39

Given 2 functions, which should be faster, if there is any difference at all? Assume that the input data is very large

void iterate1(const char* pIn, int Size)
{         


        
11条回答
  •  生来不讨喜
    2021-02-06 14:05

    Why don't you try both and time them? My guess would be that they are optimized by the compiler into basically the same code. Just remember to turn on optimizations when comparing (-O3).

提交回复
热议问题