pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:1:   /*   || 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"   #include <math.h>   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"   #include "mapping.h"   #include "array.h"   #include "stralloc.h"
pike.git/src/operators.c:2862:    l=merge_multisets(sp[-2].u.multiset, sp[-1].u.multiset,    PIKE_ARRAY_OP_OR_LEFT);    }    pop_n_elems(2);    push_multiset(l);    return;    }       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;    }       case T_TYPE:    {    struct pike_type *t;    t = or_pike_types(sp[-2].u.type, sp[-1].u.type, 0);    pop_n_elems(2);    push_type_value(t);    return;