For quite a long time I've been using javascript where this
keyword is mandatory. Now, I'm programming in c++ but habit of using this
keyword remained. But the real question is - Does using this
keyword have any negative impact on performance (as in unnecessary memory access)? I mean - is code omitting this
more optimization friendly for compiler or it completely doesn't matter? Because well strictly theoretically, referring to this
is kind of referring to pointer, like opcode $reg0, [$reg1]
in assembler, which could add one more memory reference in code but i guess it should be handled by compiler in more clever way than just typical pointer, am i right?
Personally I prefer using this
because I feel a bit lost in code which doesn't use it as i don't know if some variables are members or they're local or global or what, but if it'd cause performance issues I could probably force myself to avoid it.