Branch: Tag:

2009-09-07

2009-09-07 16:46:05 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added optimization of o_or() on two arrays where the second contains a single item.

Rev: src/operators.c:1.255

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: operators.c,v 1.254 2009/08/20 16:24:36 mast Exp $ + || $Id: operators.c,v 1.255 2009/09/07 16:46:05 grubba Exp $   */      #include "global.h"
2869:       case T_ARRAY:    { +  if (sp[-1].u.array->size == 1) { +  /* Common case (typically the |= operator). */ +  int i = array_search(sp[-2].u.array, sp[-1].u.array->item, 0); +  if (i == -1) { +  f_add(2); +  } else { +  pop_stack(); +  } +  } else if ((sp[-2].u.array == sp[-1].u.array) && +  (sp[-1].u.array->refs == 2)) { +  /* Not common, but easy to detect... */ +  pop_stack(); +  } else {    struct array *a; -  a=merge_array_with_order(sp[-2].u.array, sp[-1].u.array, PIKE_ARRAY_OP_OR_LEFT); +  a=merge_array_with_order(sp[-2].u.array, sp[-1].u.array, +  PIKE_ARRAY_OP_OR_LEFT);    pop_n_elems(2);    push_array(a); -  +  }    return;    }