[PATCH 15/21] dynarray: Reimplement with nicer semantics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2013-06-26 at 11:48 +0200, David Henningsson wrote:
> On 06/19/2013 05:40 PM, Tanu Kaskinen wrote:
> > A dynamic array is a nice simple container, but the old interface
> > wasn't quite what I wanted it to be. I like GLib's way of providing
> > the free callback at the container creation time, because that way
> > the free callback doesn't have to be given every time something is
> > removed from the array.
> >
> > The allocation pattern was changed too: instead of increasing the
> > array size always by 25 when the array gets full, the size gets
> > doubled now.
> 
> Not sure if you need this now that the node ownership stuff is changed,

I guess I don't need this now, but I'd still like to have this change in
dynarray. Is it OK for you?

> but anyway, it makes sense to have both (new_size = old_size * 2 + 25), 
> both as an optimisation in the beginning, and especially so if 
> n_allocated ever gets down to zero (I don't know if that can happen).

n_allocated never decreases (at the moment anyway - I could implement
that if there is demand).

I see the point of optimizing in the beginning. Currently the array
starts with allocated size of 1, so reallocations will happen when the
size reaches 2, 3, 5, 9, 17, 33... Starting with size 25 would perhaps
be better.

-- 
Tanu



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux