Visual Studio 2010 C++: Hard coded strings leading to slow compile times -
so have file taking few minutes compile, , have narrowed down fact contains, roughly, few thousand lines of hard-coded strings being passed qt function. file auto generated source, strings represent enumeration values placed qt controls selection. example:
method a
mywidget->insertitem("my value 1, string representation of enum value 1"); mywidget->insertitem("my value 2, string representation of enum value 2"); mywidget->insertitem("my value 3, string representation of enum value 3");
...
i commented out section (around 1000 lines) of code, , replaced with:
method b
const qstring myvalues[] = { "my value 1, string representation of enum value 1", "my value 2, string representation of enum value 2", "my value 3, string representation of enum value 3", ... }; for( int item = 0; item < 1000; ++item ){ mywidget->insertitem(myvalues[item]); }
method b compiled quicker. why? have tried optimization on/off, while optimization on longer, when off, compiling takes long time method a.
edit: yes, thought number of lines effect compile time, compared time file half amount of lines of code (with few of hard coded string lines) , compiled quicker. seems file in question took exponentially longer.
thanks, daniel
Comments
Post a Comment