If I have this code: Code: void test(){ Map *m1 = new Map; .... Map *m2 = new Map; .... } I optimized to: Code: void test(){ Map *m1 = new Map; .... m1 = new Map; .... } Does this optimization makes program run slightly faster or save some memories since it does not have to create another variable?
You are only saving the size of the address storage because any way you are allocating the memory for the variable.