Branch: Tag:

2001-06-07

2001-06-07 08:26:48 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

optimized the range operator

Rev: src/array.c:1.107
Rev: src/array.h:1.36
Rev: src/docode.c:1.113
Rev: src/interpret_functions.h:1.56

23:   #include "stuff.h"   #include "bignum.h"    - RCSID("$Id: array.c,v 1.106 2001/06/06 02:22:38 mast Exp $"); + RCSID("$Id: array.c,v 1.107 2001/06/07 08:26:46 hubbe Exp $");      PMOD_EXPORT struct array empty_array=   {
79:    v->flags=0;       v->malloced_size = DO_NOT_WARN((INT32)(size + extra_space)); +  v->item=v->real_item;    v->size = DO_NOT_WARN((INT32)size);    INIT_PIKE_MEMOBJ(v);    LINK_ARRAY(v);
515:    if(d_flag > 1) array_check_type_field(v);   #endif    -  if(start==0 && v->refs==1) /* Can we use the same array? */ + #if 1 +  if(v->refs==1) /* Can we use the same array? */    { -  +  if((end-start) && +  (end-start)*2 > v->malloced_size +4 ) /* don't waste too much memory */ +  {    add_ref(v); -  return array_shrink(v,end); +  free_svalues(ITEM(v) + end, v->size - end, v->type_field); +  free_svalues(ITEM(v), start, v->type_field); +  v->item+=start; +  v->malloced_size+=start; +  v->size=end-start; +  return v;    } -  +  } + #endif       a=allocate_array_no_init(end-start,0);    a->type_field = v->type_field;