pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:11728: Inside #if 0
  #if 0    fprintf(stderr, "Identifier \"%s\" is not strictly compatible.\n",    bid->name->str);   #endif /* 0 */    }    }    }    return 1;   }    - #define IMPLEMENTS_CACHE_SIZE 4711 + #define IMPLEMENTS_CACHE_SIZE 1024   struct implements_cache_s { INT32 aid, bid, ret; };   static struct implements_cache_s implements_cache[IMPLEMENTS_CACHE_SIZE];    -  + static int implements_hval( INT32 aid, INT32 bid ) + { +  return ((aid<<4) ^ bid ^ (aid>>4)) & (IMPLEMENTS_CACHE_SIZE-1); + } +    /* returns 1 if a implements b, but faster */   PMOD_EXPORT int implements(struct program *a, struct program *b)   {    unsigned long hval;    if(!a || !b) return -1;    if(a==b) return 1;    -  hval = (unsigned)a->id*9248339 + (unsigned)b->id; -  hval %= IMPLEMENTS_CACHE_SIZE; - #ifdef PIKE_DEBUG -  if(hval >= IMPLEMENTS_CACHE_SIZE) -  Pike_fatal("Implements_cache failed!\n"); - #endif +  hval = implements_hval(a->id,b->id);    if(implements_cache[hval].aid==a->id && implements_cache[hval].bid==b->id)    {    return implements_cache[hval].ret;    }    /* Do it the tedious way */    implements_cache[hval].aid=a->id;    implements_cache[hval].bid=b->id;    implements_cache[hval].ret = 1; /* Tentatively compatible. */    implements_cache[hval].ret = low_implements(a,b);    /* NOTE: If low_implements() returns 0, the cache may have received
pike.git/src/program.c:11824:       /* Order the id's so we don't need double entries in the cache. */    aid = a->id;    bid = b->id;    if (aid > bid) {    int tmp = aid;    aid = bid;    bid = tmp;    }    -  hval = (unsigned long)aid*9248339 + (unsigned long)bid; -  hval %= IMPLEMENTS_CACHE_SIZE; - #ifdef PIKE_DEBUG -  if(hval >= IMPLEMENTS_CACHE_SIZE) -  Pike_fatal("Implements_cache failed!\n"); - #endif +  hval = implements_hval(aid,bid);    if(is_compatible_cache[hval].aid==aid &&    is_compatible_cache[hval].bid==bid)    {    return is_compatible_cache[hval].ret;    }    if(implements_cache[hval].aid==aid &&    implements_cache[hval].bid==bid &&    implements_cache[hval].ret)    {    /* a implements b */    return 1;    } -  rhval = (unsigned long)bid*9248339 + (unsigned long)aid; -  rhval %= IMPLEMENTS_CACHE_SIZE; - #ifdef PIKE_DEBUG -  if(rhval >= IMPLEMENTS_CACHE_SIZE) -  Pike_fatal("Implements_cache failed!\n"); - #endif +  rhval = implements_hval(bid,aid);    if(implements_cache[rhval].aid==bid &&    implements_cache[rhval].bid==aid &&    implements_cache[rhval].ret)    {    /* b implements a */    return 1;    }    /* Do it the tedious way */    is_compatible_cache[hval].aid=aid;    is_compatible_cache[hval].bid=bid;