Branch: Tag:

2010-07-11

2010-07-11 12:30:45 by 0

Two optimizations: Speed up array zeroing and get rid of add_ref/sub_ref/
add_ref sequence when copying an empty array.

Rev: src/array.c:1.228

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: array.c,v 1.227 2010/07/01 09:16:05 grubba Exp $ + || $Id: array.c,v 1.228 2010/07/11 12:30:45 jonasw Exp $   */      #include "global.h"
80:    ptrdiff_t extra_space)   {    struct array *v; -  ptrdiff_t e; +        if(size+extra_space == 0)    {
116:    INIT_PIKE_MEMOBJ(v);    DOUBLELINK (first_array, v);    -  MEMSET(v->real_item, 0, sizeof(struct svalue) * size); -  for(e=0;e<size;e++) { -  v->item[e].type=T_INT; +  { +  struct svalue *item = ITEM(v); +  struct svalue *item_end = item + v->size; +  while (item < item_end) +  *item++ = svalue_int_zero;    }       return v;
2432:   #endif       if (!a->size) { -  add_ref(&empty_array); -  return array_set_flags(&empty_array, a->flags); +  ret = (a->flags & ARRAY_WEAK_FLAG) ? &weak_empty_array : &empty_array; +  add_ref(ret); +  return ret;    }       ret=allocate_array_no_init(a->size,0);