Let's say I have a C ++ class whose implementation looks something like this:
// ... MyClass::iterativeFunction() { for (int i = 0; i < 1000000; i++) { performAction(i); } } MyClass::performAction(int index) { // Block of code (non-inline-able) } // ...
At the C ++ level, do I have any control over the spatial locale of these methods, or do I just need to hope that the compiler will notice the related methods and optimize its assembly accordingly? Ideally, I would like them to be next to each other, so they will be loaded into the cache together, but I have no idea how to tell the compiler that I really like it.
source share