Branch: Tag:

1997-03-14

1997-03-14 04:39:20 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

modified check_all_args(), should be much more flexible now

Rev: src/ChangeLog:1.88
Rev: src/interpret.c:1.36
Rev: src/language.yacc:1.32
Rev: src/lex.c:1.19
Rev: src/mapping.c:1.15
Rev: src/module_support.c:1.4
Rev: src/module_support.h:1.4
Rev: src/modules/Yp/yp.c:1.4
Rev: src/modules/files/file.c:1.30
Rev: src/modules/system/system.c:1.14
Rev: src/operators.c:1.12
Rev: src/peep.in:1.7
Rev: src/pike_types.c:1.19
Rev: src/svalue.h:1.7

5:   \*/   #include <math.h>   #include "global.h" - RCSID("$Id: operators.c,v 1.11 1997/03/11 23:32:32 grubba Exp $"); + RCSID("$Id: operators.c,v 1.12 1997/03/14 04:37:17 hubbe Exp $");   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"
511:    }   }    + /* This function is used to speed up or/xor/and on +  * arrays multisets and mappings. This is done by +  * calling the operator for each pair of arguments +  * first, then recursively doing the same on the +  * results until only one value remains. +  */ + static void speedup(INT32 args, void (*func)(void)) + { +  switch(sp[-args].type) +  { +  case T_MAPPING: +  case T_ARRAY: +  case T_MULTISET: +  { +  int e=-1; +  while(args > 1) +  { +  struct svalue tmp; +  func(); +  args--; +  e++; +  if(e - args >= -1) +  { +  e=0; +  }else{ +  tmp=sp[e-args]; +  sp[e-args]=sp[-1]; +  sp[-1]=tmp; +  } +  } +  return; +  } +  +  default: +  while(--args > 0) func(); +  } + } +    void f_and(INT32 args)   {    switch(args)
523:    {    CALL_OPERATOR(LFUN_AND, args);    }else{ -  while(--args > 0) o_and(); +  speedup(args, o_and);    }    }   }
623:    {    CALL_OPERATOR(LFUN_OR, args);    } else { -  while(--args > 0) o_or(); +  speedup(args, o_or);    }    }   }
724:    {    CALL_OPERATOR(LFUN_XOR, args);    } else { -  while(--args > 0) o_xor(); +  speedup(args, o_xor);    }    }   }