On Wed, Jun 13, 2012 at 08:36:52PM +0200, Thiago Macieira wrote: > On quarta-feira, 13 de junho de 2012 18.14.59, aaron.kenn...@nokia.com > wrote: > > Won't a QString always require an allocation for the d-ptr? So > > it'll never be quite as cheap as QStringRef. > > Not exactly. > > A QStringRef points to an existing QString. Therefore, if we take a > QString that is pointing to a substring of an existing QString, the > d-ptr is already allocated. The new QString would be as cheap as the > current QStringRef. > > The issue we'll run into is that a substring could be "holding > hostage" a huge chunk of memory.
This is not much different from current usage. The difference would be the "outer" string contents being re-allocated as result of non-const operations on it. This "works" (to a certain degree...) with QStringRef, but wouldn't with "cheap substrings". However, I still have to see such a "mutable" case in practice. The QStringRef uses I am aware of are very limited in scope, often just saving a single copy of (parts of) the owning strings. Nice, but not even close to the potential of "cheap substrings". Andre' _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development