From e552234ba4467969918b2b1c5eb722c4b29f9a6d Mon Sep 17 00:00:00 2001 From: luben Date: Mon, 16 Aug 2010 17:22:24 +0300 Subject: [PATCH 8/9] Rename INITIAL_BUCKETS to INITIAL_SIZE INITIAL_BUCKETS name is misleading. This define is used for the size of the index. The number of allocated buckets is N_BUCKETS(INITIAL_SIZE) and could be differend. --- src/hash.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hash.c b/src/hash.c index 74ee64e..07a9b18 100644 --- a/src/hash.c +++ b/src/hash.c @@ -28,7 +28,7 @@ C<< hash->buckets >> bucket store points to this region. /* the number of entries above which it's faster to hash the hashval instead of * looping over the used HashBuckets directly */ -#define INITIAL_BUCKETS 8 +#define INITIAL_SIZE 8 /* HEADERIZER HFILE: include/parrot/hash.h */ @@ -1014,33 +1014,33 @@ parrot_create_hash(PARROT_INTERP, PARROT_DATA_TYPE val_type, Hash_key_type hkey_ ASSERT_ARGS(parrot_create_hash) HashBucket *bp; void *alloc = Parrot_gc_allocate_memory_chunk_with_interior_pointers( - interp, sizeof (Hash) + HASH_ALLOC_SIZE(INITIAL_BUCKETS)); + interp, sizeof (Hash) + HASH_ALLOC_SIZE(INITIAL_SIZE)); Hash * const hash = (Hash*)alloc; size_t i; - PARROT_ASSERT(INITIAL_BUCKETS % 4 == 0); + PARROT_ASSERT(INITIAL_SIZE % 4 == 0); hash->compare = compare; hash->hash_val = keyhash; hash->entry_type = val_type; hash->key_type = hkey_type; hash->seed = interp->hash_seed; - hash->mask = INITIAL_BUCKETS - 1; + hash->mask = INITIAL_SIZE - 1; hash->entries = 0; hash->free_list = NULL; hash->buckets = (HashBucket *)((char *)alloc + sizeof (Hash));; - hash->index = (HashBucket **)(hash->buckets + N_BUCKETS(INITIAL_BUCKETS)); + hash->index = (HashBucket **)(hash->buckets + N_BUCKETS(INITIAL_SIZE)); /* fill free_list from hi addresses so that we can use * buckets[i] directly in an OrderedHash, *if* nothing * was deleted */ - bp = (hash->buckets + N_BUCKETS(INITIAL_BUCKETS)); + bp = (hash->buckets + N_BUCKETS(INITIAL_SIZE)); - for (i = 0, --bp; i < N_BUCKETS(INITIAL_BUCKETS); ++i, --bp) { + for (i = 0, --bp; i < N_BUCKETS(INITIAL_SIZE); ++i, --bp) { bp->next = hash->free_list; hash->free_list = bp; } -- 1.7.1