[Development] Upgrading the sources to C++11 keywords (Q_NULLPTR, etc.)

Olivier Goffart olivier at woboq.com
Tue Feb 10 17:33:03 CET 2015


On Tuesday 10 February 2015 17:08:55 Julien Blanc wrote:
> On 10/02/2015 16:33, Knoll Lars wrote:
> > IMO there’s simply too many questions that this one example doesn’t answer
> > to conclude that what we are doing is bad.
> 
> Two arguments :
> - implicit sharing is convenient, and really developer friendly. It is
> probably a good idea since strings are really present a lot in signals
> and slots (and afaik, passed by value in these context)
> - implicit sharing is implicit, you don’t have the choice not to pay for
> it, which is a bad thing.
> 
>  From my experience, QStrings are slow. About two times slower than
> using plain std::string in our use cases, but the culprit for this
> slowness is, as far as we know, the internal 16 bits encoding, whereas
> our data sources are all using utf-8. We have no evidence that the
> implicit sharing cost is significant or not.

std::string is NOT an equivalent of QString

The equivalent of QString would be std::wstring or std::u16string.
The equivalent of std::string would be QByteArray.

Note that some STL implementation (most notably the GNU one) use implicit 
sharing for std::string

> Now the question is, is there some simple way to disable QString (and
> eventually other data structures) implicit sharing to make some real
> world benchmarks ?

There is no easy way.

My guess is that if you were to disable implicit sharing, the impact would be 
negative in almost all applications since they would suddenly do many more 
allocation. (they were developed with implicit sharing in mind)

Also, we don't share data structures among threads so much in a typical 
application. So the arguments given against implicit sharing are not really 
valid.

-- 
Olivier 

Woboq - Qt services and support - http://woboq.com - http://code.woboq.org




More information about the Development mailing list