Branch: Tag:

2014-05-20

2014-05-20 14:15:30 by Per Hedbor <ph@opera.com>

Save about 10Kb of code size by doing smarter inlining.

389:   void f_min(INT32 args);   void f_max(INT32 args);    - static void stat_index(INT32 args) + static void _stat_index(INT_TYPE code)   { -  if (!args) -  SIMPLE_TOO_FEW_ARGS_ERROR("Stat `[]",1); -  else if (args==1) -  { -  if (TYPEOF(sp[-1]) == T_INT) -  { -  int index = sp[-1].u.integer; -  pop_stack(); -  stat_push_compat(index); -  } -  else if (TYPEOF(sp[-1]) == T_STRING) -  { -  INT_TYPE code; -  -  ref_push_mapping(stat_map); -  push_svalue (sp-2); -  f_index(2); -  code = sp[-1].u.integer; /* always integer there now */ -  pop_stack(); -  +     if (!code) {    /* Fall back to a normal index on this object, in case    * someone inherited us. */
420:    *sp++ = res;    return;    } -  pop_stack(); +        switch (code)    {
562:    push_constant_text("-");       f_add(10); -  +     break; -  + #ifdef PIKE_DEBUG    default:    Pike_fatal ("stat_index is not kept up-to-date with stat_map.\n"); -  + #endif    }   } -  +  + static void stat_index(INT32 args) + { +  if( !args ) +  SIMPLE_TOO_FEW_ARGS_ERROR("Stat `[]",1); +  else if( args == 1 ) +  { +  if (TYPEOF(sp[-1]) == T_INT) +  { +  int index = sp[-1].u.integer; +  pop_stack(); +  stat_push_compat(index); +  } +  else if( TYPEOF(sp[-1]) == T_STRING ) +  { +  struct svalue *tmp; +  tmp = low_mapping_string_lookup( stat_map, sp[-1].u.string ); +  _stat_index( tmp ? tmp->u.integer : 0 ); +  }    else    SIMPLE_BAD_ARG_ERROR("Stat `[]",1,"int(0..6)|string");    }
611:    }   }    +    static void stat_index_set (INT32 args)   {    int got_int_val = 0;
862:    case 'O':    n++; push_constant_text("Stat(");    -  ref_push_string(stat_index_strs[STAT_MODE_STRING]); -  n++; stat_index(1); +  n++; _stat_index(STAT_MODE_STRING);       n++; push_constant_text(" ");    -  ref_push_string(stat_index_strs[STAT_SIZE]); -  n++; stat_index(1); +  n++; _stat_index(STAT_SIZE);    n++; push_constant_text("b)");    f_add(n);    return;