[Qt-interest] changes of QByteArray in 4.4.0

Philippe philwave at gmail.com
Thu Apr 16 12:54:48 CEST 2009


Nice that you care about this kind of low-level optimizations, because
atomic operations have a cost when used too much.

Philippe

On Thu, 16 Apr 2009 12:47:05 +0200
"Bradley T. Hughes" <bradley.hughes at nokia.com> wrote:

> Markus.Klinik at elektrobit.com wrote:
> > Hi!
> > 
> > There was a change in QByteArray (src/corelib/tools/qbytearray.cpp) in the
> > transition from release 4.3.5 to 4.4.0 that produces diffs like this, or
> > similar, at several places in that file:
> > 
> > -    x = qAtomicSetPtr(&d, x);
> > -    if (!x->ref.deref())
> > -         qFree(x);
> > +    if (!d->ref.deref())
> > +         qFree(d);
> > +    d = x;
> > 
> > It looks like a race condition was sorted out, because the pointer assignment
> > was moved to the end.
> > 
> > Does somebody remember what the problem was? I can't find anything on the
> > mailing list, in the task tracker or in the Changelog.
> 
> This is an optimization change that was done in all of our implicitly shared 
> classes to avoid the unnecessary atomic fetch-and-store. Only the reference 
> count needs to be updated atomically, not the d-pointer itself.
> 
> -- 
> Bradley T. Hughes (Nokia-D-Qt/Oslo), bradley.hughes at nokia.com
> Sandakervn. 116, P.O. Box 4332 Nydalen, 0402 Oslo, Norway
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest





More information about the Qt-interest-old mailing list