comparison src/gccache-gtk.c @ 2515:de9952d2ed18

[xemacs-hg @ 2005-01-26 10:22:19 by ben] Hash table cleanups, part 1 of 2 emacs-marshals.c, hash.c, hash.h, ui-gtk.c: Clean up and generalize creation of string hash tables. ui-gtk.c, elhash.h, gccache-gtk.c, glyphs-gtk.c, lrecord.h, marker.c, objects-gtk.c, objects-msw.c, objects-tty.c, objects-x.c, objects.c, opaque.c, rangetab.c, specifier.c, specifier.h, xgccache.c: Use Hashcode rather than unsigned long.
author ben
date Wed, 26 Jan 2005 10:22:29 +0000
parents 3d8143fc88e1
children b3ce27ca7647
comparison
equal deleted inserted replaced
2514:b49d38bc659d 2515:de9952d2ed18
89 int create_count; 89 int create_count;
90 int delete_count; 90 int delete_count;
91 }; 91 };
92 92
93 #ifdef GCCACHE_HASH 93 #ifdef GCCACHE_HASH
94 static unsigned long 94 static Hashcode
95 gc_cache_hash (const void *arg) 95 gc_cache_hash (const void *arg)
96 { 96 {
97 const struct gcv_and_mask *gcvm = (const struct gcv_and_mask *) arg; 97 const struct gcv_and_mask *gcvm = (const struct gcv_and_mask *) arg;
98 unsigned long *longs = (unsigned long *) &gcvm->gcv; 98 unsigned long *longs = (unsigned long *) &gcvm->gcv;
99 unsigned long hash = gcvm->mask; 99 Hashcode hash = gcvm->mask;
100 unsigned int i; 100 unsigned int i;
101 /* This could look at the mask and only use the used slots in the 101 /* This could look at the mask and only use the used slots in the
102 hash code. That would win in that we wouldn't have to initialize 102 hash code. That would win in that we wouldn't have to initialize
103 every slot of the gcv when calling gc_cache_lookup. But we need 103 every slot of the gcv when calling gc_cache_lookup. But we need
104 the hash function to be as fast as possible; some timings should 104 the hash function to be as fast as possible; some timings should
105 be done. */ 105 be done. */
106 for (i = 0; i < (sizeof (GdkGCValues) / sizeof (unsigned long)); i++) 106 for (i = 0; i < (sizeof (GdkGCValues) / sizeof (unsigned long)); i++)
107 hash = (hash<<1) ^ *longs++; 107 hash = (hash << 1) ^ *longs++;
108 return hash; 108 return hash;
109 } 109 }
110 110
111 #endif /* GCCACHE_HASH */ 111 #endif /* GCCACHE_HASH */
112 112