[svn:parrot] r48570 - in trunk: include/parrot src
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Thu Aug 19 16:06:24 UTC 2010
Author: chromatic
Date: Thu Aug 19 16:06:24 2010
New Revision: 48570
URL: https://trac.parrot.org/parrot/changeset/48570
Log:
[hash] Renamed hash->bucket_indices to hash->index.
Patch courtesy Luben Karavelov, TT #1741.
Modified:
trunk/include/parrot/hash.h
trunk/src/hash.c
Modified: trunk/include/parrot/hash.h
==============================================================================
--- trunk/include/parrot/hash.h Thu Aug 19 16:06:20 2010 (r48569)
+++ trunk/include/parrot/hash.h Thu Aug 19 16:06:24 2010 (r48570)
@@ -51,7 +51,7 @@
HashBucket *buckets;
/* List of Bucket pointers */
- HashBucket **bucket_indices;
+ HashBucket **index;
/* Store for empty buckets */
HashBucket *free_list;
@@ -87,8 +87,10 @@
UINTVAL _found = 0; \
while (_found < _hash->entries){ \
if (_bucket->key){ \
- _code \
_found++; \
+ { \
+ _code \
+ } \
} \
_bucket++; \
} \
@@ -98,7 +100,7 @@
{ \
INTVAL _loc; \
for (_loc = (_hash)->mask; _loc >= 0; --_loc) { \
- HashBucket *_bucket = (_hash)->bucket_indices[_loc]; \
+ HashBucket *_bucket = (_hash)->index[_loc]; \
while (_bucket) { \
_code \
_bucket = _bucket->next; \
@@ -116,7 +118,7 @@
/* If there is no more buckets */ \
if ((_loc) == (INTVAL)(_hash)->mask+1) \
break; \
- (_bucket) = (_hash)->bucket_indices[_loc++]; \
+ (_bucket) = (_hash)->index[_loc++]; \
} \
}
Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c Thu Aug 19 16:06:20 2010 (r48569)
+++ trunk/src/hash.c Thu Aug 19 16:06:24 2010 (r48570)
@@ -800,7 +800,7 @@
| --> buckets | |
+---+---+---+-+-+-+-+
^ ^
- | old_mem | hash->bucket_indices
+ | old_mem | hash->index
*/
/* resize mem */
@@ -821,7 +821,7 @@
| buckets | old_bi | new_bi |
+---+---+---+---+---+---+-+-+-+-+-+-+-+-+
^ ^
- | new_mem | hash->bucket_indices
+ | new_mem | hash->index
*/
bs = new_mem;
@@ -835,7 +835,7 @@
mem_sys_memmove(new_bi, old_bi, old_size * sizeof (HashBucket *));
/* update hash data */
- hash->bucket_indices = new_bi;
+ hash->index = new_bi;
hash->buckets = bs;
hash->mask = new_size - 1;
@@ -1033,7 +1033,7 @@
hash->buckets = bp;
bp += N_BUCKETS(INITIAL_BUCKETS);
- hash->bucket_indices = (HashBucket **)bp;
+ hash->index = (HashBucket **)bp;
for (i = 0, --bp; i < N_BUCKETS(INITIAL_BUCKETS); ++i, --bp) {
bp->next = hash->free_list;
@@ -1113,7 +1113,7 @@
UINTVAL i;
for (i = 0; i <= hash->mask; ++i) {
- HashBucket *bucket = hash->bucket_indices[i];
+ HashBucket *bucket = hash->index[i];
while (bucket) {
mem_gc_free(interp, bucket->key);
func(bucket->value);
@@ -1238,7 +1238,7 @@
/* if the fast search didn't work, try the normal hashing search */
{
const UINTVAL hashval = get_hash_val(interp, hash, key);
- HashBucket *bucket = hash->bucket_indices[hashval & hash->mask];
+ HashBucket *bucket = hash->index[hashval & hash->mask];
const hash_comp_fn compare = hash->compare;
while (bucket) {
@@ -1320,7 +1320,7 @@
{
ASSERT_ARGS(parrot_hash_put)
const UINTVAL hashval = get_hash_val(interp, hash, key);
- HashBucket *bucket = hash->bucket_indices[hashval & hash->mask];
+ HashBucket *bucket = hash->index[hashval & hash->mask];
const hash_comp_fn compare = hash->compare;
/* See if we have an existing value for this key */
@@ -1349,8 +1349,8 @@
hash->free_list = bucket->next;
bucket->key = key;
bucket->value = value;
- bucket->next = hash->bucket_indices[hashval & hash->mask];
- hash->bucket_indices[hashval & hash->mask] = bucket;
+ bucket->next = hash->index[hashval & hash->mask];
+ hash->index[hashval & hash->mask] = bucket;
}
return bucket;
@@ -1373,7 +1373,7 @@
{
ASSERT_ARGS(parrot_hash_delete)
const UINTVAL hashval = (hash->hash_val)(interp, key, hash->seed) & hash->mask;
- HashBucket **prev = &hash->bucket_indices[hashval];
+ HashBucket **prev = &hash->index[hashval];
if (*prev) {
const hash_comp_fn compare = hash->compare;
for (; *prev; prev = &(*prev)->next) {
More information about the parrot-commits
mailing list