Author: cotto
Date: Wed Dec 17 14:59:48 2008
New Revision: 34052
Modified:
trunk/include/parrot/hash.h
trunk/src/hash.c
trunk/src/pmc/orderedhash.pmc
Log:
[hash] move some hash-related macros to hash.h, restore old N_BUCKETS macro,
make OrderedHash use it
Modified: trunk/include/parrot/hash.h
==============================================================================
--- trunk/include/parrot/hash.h (original)
+++ trunk/include/parrot/hash.h Wed Dec 17 14:59:48 2008
@@ -38,6 +38,10 @@
typedef UINTVAL BucketIndex;
#define INITBucketIndex ((BucketIndex)-2)
+#define N_BUCKETS(n) ((n) - (n)/4)
+#define HASH_ALLOC_SIZE(n) (N_BUCKETS(n) * sizeof (HashBucket) + \
+ (n) * sizeof (HashBucket *))
+
typedef int (*hash_comp_fn)(PARROT_INTERP, const void*const, const void*const);
typedef void (*hash_mark_key_fn)(PARROT_INTERP, PObj *);
typedef size_t (*hash_hash_key_fn)(PARROT_INTERP, ARGIN(const void *), size_t
seed);
Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c (original)
+++ trunk/src/hash.c Wed Dec 17 14:59:48 2008
@@ -31,10 +31,6 @@
#define INITIAL_BUCKETS 16
-#define N_BUCKETS(n) (n)
-#define HASH_ALLOC_SIZE(n) (N_BUCKETS(n) * sizeof (HashBucket) + \
- (n) * sizeof (HashBucket *))
-
/* HEADERIZER HFILE: include/parrot/hash.h */
/* HEADERIZER BEGIN: static */
Modified: trunk/src/pmc/orderedhash.pmc
==============================================================================
--- trunk/src/pmc/orderedhash.pmc (original)
+++ trunk/src/pmc/orderedhash.pmc Wed Dec 17 14:59:48 2008
@@ -583,8 +583,7 @@
Hash * const h_dest = (Hash *)PMC_struct_val(dest);
UINTVAL i;
- /* see N_BUCKETS in src/hash.c; 3/4 of the available bucket slots */
- for (i = 0; i <= ((hash->mask - 1) * 3 / 4); i++) {
+ for (i = 0; i <= N_BUCKETS(hash->mask+1); i++) {
HashBucket * const b = hash->bs + i;
void * const key = b->key;