ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/mgflib/lookup.c
(Generate patch)

Comparing ray/src/cv/mgflib/lookup.c (file contents):
Revision 1.3 by greg, Thu Jun 23 08:48:28 1994 UTC vs.
Revision 1.4 by greg, Sat Jun 25 16:33:07 1994 UTC

# Line 42 | Line 42 | int    nel;
42   }
43  
44  
45 < int
46 < lu_hash(s)                      /* hash a nul-terminated string */
45 > long
46 > lu_shash(s)                     /* hash a nul-terminated string */
47   register char  *s;
48   {
49 <        register int  h = 0;
49 >        register int    i = 0;
50 >        register long   h = 0;
51  
52          while (*s)
53 <                h = (h<<1 & 0x7fff) ^ (*s++ & 0xff);
53 >                h ^= (long)(*s++ & 0xff) << (i++ & 15);
54          return(h);
55   }
56  
# Line 59 | Line 60 | lu_find(tbl, key)              /* find a table entry */
60   register LUTAB  *tbl;
61   char    *key;
62   {
63 <        int  hval, i;
64 <        register int  ndx;
65 <        register LUENT  *oldtabl;
63 >        long    hval;
64 >        int     i;
65 >        register int    ndx;
66 >        register LUENT  *oldtabl;
67                                          /* look up object */
68 <        hval = lu_hash(key);
68 >        hval = (*tbl->hashf)(key);
69   tryagain:
70          for (i = 0; i < tbl->tsiz; i++) {
71                  ndx = (hval + i*i) % tbl->tsiz;
72 <                if (tbl->tabl[ndx].key == NULL ||
73 <                                !strcmp(tbl->tabl[ndx].key, key))
72 >                if (tbl->tabl[ndx].key == NULL) {
73 >                        tbl->tabl[ndx].hval = hval;
74 >                        return(&tbl->tabl[ndx]);
75 >                }
76 >                if ( tbl->tabl[ndx].hval == hval && (tbl->keycmp == NULL ||
77 >                                !(*tbl->keycmp)(tbl->tabl[ndx].key, key)) )
78                          return(&tbl->tabl[ndx]);
79          }
80                                          /* table is full, reallocate */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines