Assuming a loop that reads a lot of values from an std::vector is a bottleneck in my program, it has been suggested I change
void f(std::vector<int> v)
{
...
while (...)
{
...
int x = v[i] + v[j]
...
}
}
to
void f(std::vector<int> v)
{
int* p_v = &v[0];
...
while (...)
{
...
int x = p_v[i] + p_v[j]
...
}
}
Will this actually improve performance, by by-passing the [] operator?