kdelibs/kdecore
Stefan Heimers
kde-optimize@mail.kde.org
Wed, 19 Mar 2003 21:47:24 +0100
Am Wednesday 19 March 2003 21:12 schrieb Eray Ozkural:
> --- kdelibs/kdecore/netwm.cpp #1.84:1.85
> @@ -475,5 +475,7 @@ Z &NETRArray<Z>::operator[](int index) {
> } else if (index >= sz) {
> // allocate space for the new data
> - Z *newdata = new Z[index + 1];
> + // open table has amortized O(1) access time
> + // when N elements appended -- exa
> + Z *newdata = new Z[max(2 * sz, index+1)];
In my experience, the worst about KDE ist its huge memory usage, while
CPU is nearly a non-issue (any old Pentium is fine, if you have enough
RAM). Your solution will eat even more memory, while giving only a
little improvement in CPU usage.
I think the solution provided by Michael Matz is a good compromise.
In QT, Qstring was allocating the next power of two of the requested
size earlyer, but they reduced it now for larger requested sizes.
Stefan