Stop Microsoft
Miscellaneous => Programming & Networking => Topic started by: anphanax on 3 March 2006, 07:17
-
// Zero characters are repeated in compiled EXE.
char *value1 = "0", *value2 = "0";
char *value3 = "0", *value4 = "1";
// Zero character only appears once in data.
char *ZERO = "0"; char *ONE = "1";
char *value1 = ZERO, *value2 = ZERO;
char *value3 = ZERO, *value4 = ONE;
Is there a reason why duplicate string entries wouldn't be optimized and all point to the same data? Those character arrays shouldn't be editable in the first place (although they were in VC++ 5.0 and lesser), so i'm kind curious why that sort of optimization is absent. I know Java does it.
EDIT: Compiling in Release Mode, not Debug.
-
Are they in the same source file? How many other strings in the file are there?
I've played around in some executables and even common floating point numbers are reused.
There would not be any issues involving such optimisations.
I'll test gcc.
-
gcc does it:
#include
int main (int argc, char *argv[])
{
char * a = "0";
char * b = "0";
std::cout << "a = " << ((int) a) << std::endl;
std::cout << "b = " << ((int) b) << std::endl;
return 0;
}
output:
a = 4199088
b = 4199088
-
// Zero characters are repeated in compiled EXE.
char *value1 = "0", *value2 = "0";
char *value3 = "0", *value4 = "1";
// Zero character only appears once in data.
char *ZERO = "0"; char *ONE = "1";
char *value1 = ZERO, *value2 = ZERO;
char *value3 = ZERO, *value4 = ONE;
Is there a reason why duplicate string entries wouldn't be optimized and all point to the same data? Those character arrays shouldn't be editable in the first place (although they were in VC++ 5.0 and lesser), so i'm kind curious why that sort of optimization is absent. I know Java does it.
EDIT: Compiling in Release Mode, not Debug.
Aren't those already pre-buffered in the framework (annoyingly so)?
-
what is that supposed to mean?
-
No clue :D
-
what is that supposed to mean?
Welcome to the wonderfull world of Microsoft Visual Studio .NET :rolleyes:
-
I assumed by C++ he meant good old MSVC 6.0
If it is .NET meh who knows...
The Java buffering or what ever had some rather ugly side affects and no real performance gain so I would agree with MS on this one if they chose against implementing it.
does C++ .Net use handles like C# ? Whats the difference between C++ .NET and C++?