KGlobal::staticQString current recomendation harmful?
Simon Hausmann
kde-optimize@mail.kde.org
Sun, 12 Jan 2003 12:01:10 +0100
On Sun, Jan 12, 2003 at 04:48:25AM +0100, Roger Larsson wrote:
> Hi,
>
> From the documentation.
>
> /**
> * Creates a static QString.
> *
> * To be used inside functions(!) like:
> * <pre>
> * static const QString &myString = KGlobal::staticQString("myText");
> * </pre>
> *
> [CONTINUED later]
>
> "Use inside of functionS"
> OK, so what if I have 100 functions that uses the same string?
> then the function staticQString need to run 100 times at startup.
> later when running it is no problem but... startup time is an issue too!
> [Current CVS with my run have 251 misses and 171 hits
> - pretty bad hit rate that is, patch included]
I think the main idea behind staticQString is less to share as much
data as possible (nice side effect) but more to get around the
problem that some platforms we support have problems with static
objects in functions (them not calling the constructor or destructor
under certain circumstances) . I can't imagine it to be really
relevant to startup time of applications.
Simon