[Development] RFD: plugins vs QStringLiterals
thiago.macieira at intel.com
Thu Nov 5 21:55:29 CET 2015
On Thursday 05 November 2015 21:06:20 Marc Mutz wrote:
> On Thursday 05 November 2015 17:44:33 Thiago Macieira wrote:
> > Proposal: force QStringLiteral uses to always address a heap-allocated
> > QString, instead of pointing to the static data. Possibly, this should be
> > an interned atom/quark à la GQuark, so two passes on the same
> > QStringLiteral would result in the same heap pointers.
> TL;DR: what's atom/quark in this context?
The documentation for XAtom and GQuark probably explains more. Basically it's
a string that becomes managed by the library and for which a pointer
comparison guarantees string comparison.
str1 == str2 ←→ &str1 == &str2
Obviously this is more useful for when you have pointers (GQuark) or you have
some other form of identifier (XAtom).
The benefit for us is that it would allocate memory only on the first use.
After that, it always returns the same pre-allocated string data.
We'd implement it using a QSet.
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development