Question: I have a set of multiple vectors on which I need to perform exactly the same actions in a `for` loop. And I am not sure what is a better way to do it:

```
for (/*...*/)
{
    std::rotate(/*...*/); // Vec1
    std::rotate(/*...*/); // Vec2
    std::rotate(/*...*/); // Vec3
    std::rotate(/*...*/); // Vec4
    std::rotate(/*...*/); // Vec5
}

```

Or

```
for (/*...*/)
{
    std::rotate(/*...*/); // Vec1
}

for (/*...*/)
{
    std::rotate(/*...*/); // Vec2
}

for (/*...*/)
{
    std::rotate(/*...*/); // Vec3
}

for (/*...*/)
{
    std::rotate(/*...*/); // Vec4
}

for (/*...*/)
{
    std::rotate(/*...*/); // Vec5
}

```

The first example is shorter, and there is only one `for` loop in it, but there are five different objects potentially competing for the same cache being processed in that loop "at the same time".  

In the second example there are five `for` loops vs one, but there is only one object being processed in each loop, that [[possibly]] means less cache misses.

Which is more efficient approach? Am I focused on too deep, negligible things?

Answer: 
> 
> Which of these two approaches is more cache friendly?
> 
> 
> 

If a successive iteration operates on elements that are near to those on the previous iteration, then the second approach is potentially cache friendlier.

> 
> Which is more efficient approach?
> 
> 
> 

The one which you can measure to be more efficient.
Both processes depends on your requirements. If your code on both ways result same thing then the first one is definitely efficient and short. If you have different approaches to your codes then the second one is better