Image

Imagexsvenx wrote in Imagecpp 🤔curious

Efficiency of the this pointer

OK, say you have a class like this (leave the function bodies out, just pretend :P):

class example {
public: int a(int);
int b(int);
}

Can anybody tell me if there's a difference in overhead and such between these two functions?

int b(int input) {
return a(input)+5; //what a useful function, huh?
}

int b(int input) {
return this->a(input)+5;
}

I think the second is clearer, but if it takes a decent amount more overhead... :/

I think they should be about the same, because this is already created and loaded, no? So the compiler should replace both statements with the same machine code, methinks, since they're the same function?

Thanks in advanced.
XsvenX