From e552234ba4467969918b2b1c5eb722c4b29f9a6d Mon Sep 17 00:00:00 2001
From: luben <karavelov@spnet.net>
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
|
b
|
|
28 | 28 | |
29 | 29 | /* the number of entries above which it's faster to hash the hashval instead of |
30 | 30 | * looping over the used HashBuckets directly */ |
31 | | #define INITIAL_BUCKETS 8 |
| 31 | #define INITIAL_SIZE 8 |
32 | 32 | |
33 | 33 | /* HEADERIZER HFILE: include/parrot/hash.h */ |
34 | 34 | |
… |
… |
|
1014 | 1014 | ASSERT_ARGS(parrot_create_hash) |
1015 | 1015 | HashBucket *bp; |
1016 | 1016 | void *alloc = Parrot_gc_allocate_memory_chunk_with_interior_pointers( |
1017 | | interp, sizeof (Hash) + HASH_ALLOC_SIZE(INITIAL_BUCKETS)); |
| 1017 | interp, sizeof (Hash) + HASH_ALLOC_SIZE(INITIAL_SIZE)); |
1018 | 1018 | Hash * const hash = (Hash*)alloc; |
1019 | 1019 | size_t i; |
1020 | 1020 | |
1021 | | PARROT_ASSERT(INITIAL_BUCKETS % 4 == 0); |
| 1021 | PARROT_ASSERT(INITIAL_SIZE % 4 == 0); |
1022 | 1022 | |
1023 | 1023 | hash->compare = compare; |
1024 | 1024 | hash->hash_val = keyhash; |
1025 | 1025 | hash->entry_type = val_type; |
1026 | 1026 | hash->key_type = hkey_type; |
1027 | 1027 | hash->seed = interp->hash_seed; |
1028 | | hash->mask = INITIAL_BUCKETS - 1; |
| 1028 | hash->mask = INITIAL_SIZE - 1; |
1029 | 1029 | hash->entries = 0; |
1030 | 1030 | hash->free_list = NULL; |
1031 | 1031 | |
1032 | 1032 | |
1033 | 1033 | |
1034 | 1034 | hash->buckets = (HashBucket *)((char *)alloc + sizeof (Hash));; |
1035 | | hash->index = (HashBucket **)(hash->buckets + N_BUCKETS(INITIAL_BUCKETS)); |
| 1035 | hash->index = (HashBucket **)(hash->buckets + N_BUCKETS(INITIAL_SIZE)); |
1036 | 1036 | |
1037 | 1037 | /* fill free_list from hi addresses so that we can use |
1038 | 1038 | * buckets[i] directly in an OrderedHash, *if* nothing |
1039 | 1039 | * was deleted */ |
1040 | 1040 | |
1041 | | bp = (hash->buckets + N_BUCKETS(INITIAL_BUCKETS)); |
| 1041 | bp = (hash->buckets + N_BUCKETS(INITIAL_SIZE)); |
1042 | 1042 | |
1043 | | for (i = 0, --bp; i < N_BUCKETS(INITIAL_BUCKETS); ++i, --bp) { |
| 1043 | for (i = 0, --bp; i < N_BUCKETS(INITIAL_SIZE); ++i, --bp) { |
1044 | 1044 | bp->next = hash->free_list; |
1045 | 1045 | hash->free_list = bp; |
1046 | 1046 | } |