Dan Sugalski <[EMAIL PROTECTED]> wrote:

> Okay, at this point we've a pile of different array classes

> Before we go any further we need to figure out what we want.

1) Unify setting/getting element count
   - the elements() vtable is unused (not accessible by opcode)
   - we use get_integer()
   - push for Array is unusabale currently
   - reserve array store size before filling can have performance
     benefits by avoiding reallocation

   So e.g.

   elements I0, P0      # @a.elements      #   scalar @a
   elements P0, I0      # @a.elements = I0 #   $#a = I0-1
   set I0, P0           # @a.internal_capacity
   set P0, I0           # @a.internal_capacity = I0

2) Array vs PerlArray

   - PerlArray does autoexpand and is derived from Array.
   - Array throws exceptions if you access elements beyond capacity
   - the underlying List does not do bounds checking

   So the class inheritance is wrong.

3) SArray

   - Should have been a simple typed array (At these times PerlHash
     store was typed too). Its obsolete now.

4) list.c

   - is too complicated for the current usage patterns

   A currently better implementation could be e.g.

   - one buffer array
   - a start index to accomodate shift/unshift
   - resize by 2 << n until a certain limit, then by that limit
   - after pop/shift shrink buffer by limit if limit+threshold is free

leo

Reply via email to