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
m...@milianw.de
http://milianw.de
_______________________________________________
Kde-frameworks-devel mailing list
Kde-frameworks-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-frameworks-devel

Reply via email to