optimization - Within c++ function, pointer vs indexed array -


This question is similar to what is asked, but I think memory paging is not considered. Therefore, I am presenting a similar question again:

  // version 1 int x [100]; Int * pNum = nums; {Foo (pNum) for (int i = 0; i & lt; 100; i ++, pNum ++); } // for version 2 (int i = 0; i   

Which version will be faster? Earlier, it was said that the assembly code generated would be very similar because both versions need to increase the status of the memory address, but considering a very large array, there will be a lot of change in memory paging performance? Since one of them requires a long haul of one type, but does anyone need to change the base memory address from the base? I know that this very platform / compiler is dependent, but still people want to know the common thing, especially working with large data types such as image processing or scientific computing? Thank you.

There is general consensus that for primitive types, there is no difference most compilers are the exact one for this Will generate the same code (possibly you foo (* pNum) ).

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -