On Monday, 17 de October de 2011 10:46:55 João Abecasis wrote: > This is something I want to support more generally: mmap'able data > structures, not necessarily compile time generated. At the minimum I'd like > to get an array (QVector) and a dictionary (QHash/QMap), in particular > dictionaries where the key is QString/QByteArray. We'd have to be creative > and directly abuse QStringData/QByteArrayData (or a unified QArrayData) for > this to happen.
I want that too! But I just don't think we can have that in the standard
QVector or especially QHash. Though technically, if you have:
QVector<QStringData> vector = QVector<QStringData>::fromRawData(ptr);
You can write:
QString s = vector.at(0);
Since QString is just a pointer to QStringData and automatically (implicitly)
casts from it.
> That's in addition to the existing support for QByteArray and QString.
>
> Another variation of the array classes I've wondered about is one with a
> detached reference count, say:
>
> QStringRef
> {
> QAtomicInt *ref;
> int size;
> int alloc;
> qptrdiff offset;
> };
>
> Provided we can specify how data is deleted when the reference count goes to
> zero (if at all), something along those lines would allow allocation-less
> manipulation of array data coming from external sources.
I don't like a pointer to the reference count... that means an additional
indirection when doing counting up and down.
As for having a "deleter function", like QSharedPointer, it makes sense. It
would allow implementations to finally use fromRawData on mmap'ed data and be
able to eventually free that data.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Qt5-feedback mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
