Miscellaneous > Programming & Networking
MSVC++ Optimization Observation
anphanax:
// 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.
Pathos:
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.
Pathos:
gcc does it:
#include
int main (int argc, char *argv[])
{
char * a = "0";
char * b = "0";
std::cout
Refalm:
--- Quote from: anphanax ---// 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.
--- End quote ---
Aren't those already pre-buffered in the framework (annoyingly so)?
Pathos:
what is that supposed to mean?
Navigation
[0] Message Index
[#] Next page
Go to full version