Branch: Tag:

2014-10-02

2014-10-02 17:57:02 by Per Hedbor <ph@opera.com>

Added a simple append_mapping instruction.

Much like append_array, but for mappings. This speeds up the append
mapping benchmark by about (currently) 1000x.

However, that is somewhat misleading since the refs optimization is
not done currently since the wrong assignment operator ends up being
used.

Even when that is fixed the speedup should is still more than 2x,
however.

1856:    return m;   }    + void o_append_mapping( INT32 args ) + { +  struct svalue *lval = Pike_sp - args; +  struct svalue *val = lval + 2; + #ifdef PIKE_DEBUG +  if (args < 3) { +  Pike_fatal("Too few arguments to o_append_mapping(): %d\n", args); +  } + #endif +  args -= 3; +  /* Note: val should always be a zero here! */ +  lvalue_to_svalue_no_free(val, lval); +  +  if (TYPEOF(*val) == T_MAPPING) +  { +  struct mapping *m = val->u.mapping; +  if( m->refs == 2 ) +  { +  int i; +  /* fprintf( stderr, "map_refs==2\n" ); */ +  for( i=0; i<args; i+=2 ) +  low_mapping_insert( m, Pike_sp-(i+2), Pike_sp-(i+1), 0 ); +  stack_pop_n_elems_keep_top(2+args); +  return; +  } +  } +  +  f_aggregate_mapping(args); +  f_add(2); +  assign_lvalue(lval, val); +  stack_pop_2_elems_keep_top(); + } +    /* NOTE: May perform destructive operations on either of the arguments    * if it has only a single reference.    */