Branch: Tag:

2015-03-31

2015-03-31 07:15:07 by Per Hedbor <ph@opera.com>

Optimized has_index for mappings and multiset

It is now way faster for mappings (in testing about 2x) and somewhat
faster for multisets. Since our developers have a tendency to write
if(has_index(map,key)) instead of if(mapping[key]) this can be a
noticeable gain.

1366:    push_int(t);    break;    -  case T_MULTISET: +     case T_MAPPING: -  f_index(2); -  f_zero_type(1); +  t=!!low_mapping_lookup( Pike_sp[-2].u.mapping, Pike_sp-1 ); +  pop_n_elems(2); +  push_int(t); +  break;    - #ifdef PIKE_DEBUG -  if(TYPEOF(Pike_sp[-1]) != T_INT) -  PIKE_ERROR("has_index", -  "Function `zero_type' gave incorrect result.\n", Pike_sp, args); - #endif -  Pike_sp[-1].u.integer = !Pike_sp[-1].u.integer; +  case T_MULTISET: +  t = multiset_member( Pike_sp[-2].u.multiset, Pike_sp-1 ); +  pop_n_elems(2); +  push_int(t);    break;       case T_OBJECT: