KDevVarLengthArray still required?
Milian Wolff
mail at milianw.de
Tue Jan 12 19:31:08 UTC 2010
Hey there!
Is our local modificated version of QVarLengthArray (i.e. KDevVarLengthArray)
still required? I compared the sources with the one found in qt master (see
[1]) and saw that the place marked as "this is the difference" changed a bit in
Qt:
Our code:
const int idx = s++;
///This is currently the difference to KDevVarLengthArray(which uses s
== a), and it prevents a crash.
if (s >= a)
realloc(s, s<<1);
Their code:
if (s == a) // i.e. s != 0
realloc(s, s<<1);
const int idx = s++;
Esp. the reordering of the idx / s++ call could make the difference here. I
tried their code and ran a few unittests without any problems. Could we ditch
KDevVarLengthArray? It has a few extra Apis though:
removeOne, indexOf, insert, erase
All of them operate on the private ptr member...
On a different subject: an array (i.e. with consecutive memory blocks) is used
to make writing/loading from disk faster, do I see that correctly? E.g.
comment in appendedlist.h:
* This file contains macros and classes that can be used to conveniently
implement classes that store the data of an arbitrary count
* of additional lists within the same memory block directly behind the class
data, in a way that one the whole data can be stored by one copy-operation
* to another place, like needed in ItemRepository.
So I wonder: Is this really required? I mean now we suffer through the known
pitfalls of such arrays: realloc, huge mem-blocks, ... I'd still like to see a
Pool used here if possible, but I'm too much of a layman still I fear.
--
Milian Wolff
mail at milianw.de
http://milianw.de
More information about the KDevelop-devel
mailing list