[ki18n] src: small qstring optimizations
Milian Wolff
mail at milianw.de
Sun Jan 25 15:17:20 UTC 2015
On Sunday 25 January 2015 12:36:08 David Faure wrote:
> On Wednesday 21 January 2015 21:32:07 Nick Shaforostoff wrote:
> > +static const QString SUBSTITUTE_ME=QStringLiteral("%1");
>
> I'm not sure that adding global static (non-POD) objects in libraries is a
> good idea.
> We've had many problems with that in the past (see below for details), and
> they slow down application startup by having to create all these global
> objects even if they are never going to be used.
+1. And from the snippet above, is that a minified example form the code?
Because otherwise, it is a very bad thing to do. There is *no* reason to ever
do:
QString("%1").arg(foo);
Do you want to stringify a number? Use QString::number. Do you want to assign
another string? Assign it directly. Want to convert a bytearray or const char?
Use the explicit conversion functions.
> Here are my notes about why global static objects are bad:
See also: http://neugierig.org/software/chromium/notes/2011/08/static-initializers.html
--
Milian Wolff
mail at milianw.de
http://milianw.de
More information about the Kde-frameworks-devel
mailing list