[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

Kevin Kofler kevin.kofler at chello.at
Mon Jul 27 00:27:18 CEST 2015


Marc Mutz wrote:
> It makes perfect sense: A container should not subtle change memory layout
> and switch guarantees in such a way that only experts know what it
> actually does. That an array-list *might* be the most efficient container
> for certain types and certain operations, no-one disputes.

It doesn't switch the stuff it actually guarantees:
* Moving n elements in the list (for whatever reason) will only move
  n*sizeof(void*) bytes (not n*sizeof(T), nor will it call any copy
  constructors or destructors).
* Both prepending and appending is done in amortized O(1) time.
* Accessing the i-th element is performed in guaranteed O(1) time.
* Inserting an element performs at most 1 heap allocation. (This is the only
  performance metric that can change, but the changing from the usual 1 to 0
  is a very welcome optimization for the cases it applies to.)

This is exactly the kind of performance behavior a non-expert expects from 
an efficient list. And an expert knows the full details anyway.

        Kevin Kofler




More information about the Development mailing list