Let's call this one option 0:

> > Here's an idea:
> >         QAtomicInt ref;
> >         int alloc;
> >         union {
> >         
> >                 qptrdiff offset;
> >                 struct { int begin; int end; };
> >         
> >         };
> >         // size = 16 bytes

> Option 1:
> 
>       QAtomicInt ref;
>       int alloc;
>       union {
>               qptrdiff begin;
>               qint64 dummy;
>       };
>       int end;
>       int flags;
>       // size = 24 bytes

> Option 2:
> 
>       QAtomicInt ref;
>       int flags;
>       union {
>               qptrdiff alloc;
>               qint64 dummy;
>       };
>       qptrdiff begin;
>       qptrdiff end;
>       // size = 24 (32) bytes

Here's another suggestion now, with "split personality". It's not very good, 
so suggestions to improve are very much welcome.

Option 3:
struct QArrayData {
        QAtomicInt ref;
        int begin;
        int size;
        int flags;
        // size = 16 bytes
};

struct QArrayRawData {
        T *offset;
        void (*deleterFunction)(T *);
};

struct QArrayOwnData {
        int alloc;
        int hash;
        ...
};

Somewhere in the fixed header, we need an indication of whether the data is raw 
or allocated by us. It can be either a bit in the flags or a negative begin 
value (begin is unused if offset is used). I replaced the end value with size, 
which means the number of elements allocated but unused past the end is:
        alloc - begin - size

However, the calculation of the beginning of the data pointer now involves a 
comparison:
        T *data()
        { 
                if (d->isRawData()) return d->rawData()->offset;
                return d->array() + d->begin;
        }


-- 
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

Attachment: 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

Reply via email to