On Sunday 16 October 2011 16:30:39 Thiago Macieira wrote: > When I talked to João this week, he expressed the desire to unify the header > code of QVector, QByteArray and QString. Since QByteArray is a vector of > char and QString is a vector of QChar / ushort, it makes sense to unify the > code to simplify maintenance. Whether specific optimisations in allocation > policies are needed, we can figure out later.
Appart from consistency in out internal structures, what is the gain? What is the code that can be reuse? (Appart the declaration itself, i can't think of any) As this is an internal thing, this do not give us anything regarding the API point of view. And this keep us to have nice per/data structure optimisation. In other word, i'm not really in favor of this. (I think the sharing should happen at code level, by providing the same interface which enable templated code (like QStringBuilder) to work of all types.) > But given my last email, about also bringing in QList for small and movable > types into this merging, I pointed out that QList has one optimisation that > QVector doesn't have. > > To support that feature, the QListData header currently is: > > QAtomicInt ref; > int alloc; > int begin; > int end; > // size = 16 bytes, alignment = 4 bytes > > There's also an 1-bit flag which I have not included. It can be stored in > the sign bit of one of the ints in the future. > > In addition, the current QStringData and QByteArrayData headers are (not > including the flags): > > QAtomicint ref; > int size; > int alloc; > qptrdiff offset; > // size = 16 (24) bytes, alignment = 4 (8) bytes > > Note how there's a 4-byte padding gap before the "offset" member on 64-bit > platforms and how the data starts at an offset of 24 bytes. Given a 16-byte > aligned allocator, which is common on 64-bit platforms, the data starts at > an 8 byte offset from the nearest 16-byte alignment, which is a problem for > SSE2 optimisations. One thing I would like to add is the hash, for QString (and potentialy QByteArray) see: http://qt.gitorious.org/qt/qtbase/merge_requests/62 > I'd like to pick all of your brains for a solution that has the following > properties: > > - size always 16 bytes Not possible on 64bit Or did you mean "multiple of"? > - contains a qptrdiff offset, to still allow for fromRawData (which we'd > then introduce to QVector too, but not QList) And there again you are saying it will be different for QList and QVector Or you want to put a lot of unions there (which negates the hole purpose) > - can store at least one 1-bit flag, but 2 would be preferred The more flag you have, the more future proof you are if you want to keep binary compatibility. > - size calculation reasonably fast And add stuff like: - can be generate at compile time and put in the .rodata (like we did for QString) _______________________________________________ Qt5-feedback mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
