← Home ← Back to /g/

Thread 107160610

3 posts 2 images /g/
Anonymous No.107160610 [Report] >>107160662 >>107160769
void func()
{
A* a = new A();
a->foo();
A z;
z.foo();
}

Assuming foo is not virtual and ignoring allocator overhead, why might z.foo() be faster than a->foo?

You should be able to solve this
Anonymous No.107160662 [Report]
>>107160610 (OP)
I give up why?
Anonymous No.107160769 [Report]
>>107160610 (OP)
-> has to load the objects address from the stack (memory read) while the dot operator already knows the address of the object implicit from stack pointer (no mem read). ez