this
pointer, to be specific) cause about a 3% slowdown in code, for a variable that is used frequently? It was previously just an int that was accessed directly, and I stuffed it in a class, and I want to know if this slowdown is because of the extra pointer indirection, or if I''m doing something wrong with my class.
class Color {
private:
unsigned int color;
public:
Color () { }
Color (unsigned int c) : color(c) { }
void change () { color ^= 1; }
const unsigned int & to_i () const { return color; }
};
I don''t see any reason why this should be any slower than using an int and working with that directly, other than accessing it through the this
pointer.