2016-09-08 23:48 GMT+02:00 Konstantin Shegunov <kshegu...@gmail.com>: > On Thu, Sep 8, 2016 at 11:21 PM, Elvis Stansvik <elvst...@gmail.com> wrote: >> >> (I think you forgot to include the list in your reply) > > > Yes, I'm sorry about that. > >> >> I know that it's mentioned in the docs what you bring up (and that >> Thiago also brought up), that a QSP manages a *pointer*, while QESDP >> manages *data*. But I still can't say that I'm 100% sure why I can't >> do with QSP what I can do with QESDP... > > > You can, and if you find it easier you probably should. From what I've seen > QESDP is used rather rarely.
Alright. I don't find it easier/harder or anything, I was just pondering the similarities of the two classes. Because it's relatively rare to see two classes that are very similar in Qt (unless one of them is deprecated), they stood out to me. It's also my impression that QESDP is rarely used, at least compared to QSP and QSDP. I guess it's because it's a sort of "power tool" for when QSDP is too restrictive. > >> >> In this use case, I can't quite see why I couldn't use a QSP instead > > > Again, you can. Yes, sorry I should probably have said "I can't quite see why QESDP was introduced if the same could be done with QSP". > >> >> So is the difference really just the slightly different API and >> slightly different way of doing a deep copy? (I consider the >> external/internal refcount mostly a technical difference). > > > I admit you got me curious, so I looked up the source. It seems QESDP is a > bit more efficient (no external structure and custom (de)allocator) because > of the internal reference counting. It does, however, detach exactly as > you'd do manually[1]. I'd expect it'd perform marginally better for small > objects compared to QSP, whereas for big fat data structures I'd expect no > gain whatsoever. In any case as always I think one's best bet is using what > *feels* most natural to the case on hand, however esoteric this might sound. > :) Thanks a lot for having a look, and perhaps performance is then the biggest reason for QESDP's existance (instead of using QSP). Yea, QESDP seems like the natural choice if you're using it for the d member in a data class, a la QSDP (but need more control), and QSP more of a general thing. Elvis > > Kind regards, > Konstantin. > > [1]: > http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/tools/qshareddata.h#n229 _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest