Ticket #1741: 0002-rename-hash-bucket_indices-to-hash-index.patch

File 0002-rename-hash-bucket_indices-to-hash-index.patch, 6.3 KB (added by luben, 11 years ago)
  • include/parrot/hash.h

    From 075190b3e34fa330968c4c76ee0f63a4720e63dc Mon Sep 17 00:00:00 2001
    From: Luben Karavelov <karavelov@spnet.net>
    Date: Sat, 14 Aug 2010 23:49:25 +0300
    Subject: [PATCH 2/7] rename hash->bucket_indices to hash->index.
    
    ---
     include/parrot/hash.h |   10 ++++++----
     src/hash.c            |   20 ++++++++++----------
     2 files changed, 16 insertions(+), 14 deletions(-)
    
    diff --git a/include/parrot/hash.h b/include/parrot/hash.h
    index fe9bfba..c23afa6 100644
    a b  
    5151    HashBucket *buckets; 
    5252 
    5353    /* List of Bucket pointers */ 
    54     HashBucket **bucket_indices; 
     54    HashBucket **index; 
    5555 
    5656    /* Store for empty buckets */ 
    5757    HashBucket *free_list; 
     
    8787    HashBucket *_bucket = (_hash)->buckets;                                 \ 
    8888    while (_found < _hash->entries){                                        \ 
    8989        if (_bucket->key){                                                  \ 
    90             _code                                                           \ 
    9190            _found++;                                                       \ 
     91            {                                                               \ 
     92                _code                                                       \ 
     93            }                                                               \ 
    9294        }                                                                   \ 
    9395       _bucket++;                                                           \ 
    9496    }                                                                       \ 
     
    98100{                                                                           \ 
    99101    INTVAL _loc;                                                            \ 
    100102    for (_loc = (_hash)->mask; _loc >= 0; --_loc) {                         \ 
    101         HashBucket *_bucket = (_hash)->bucket_indices[_loc];                \ 
     103        HashBucket *_bucket = (_hash)->index[_loc];                         \ 
    102104        while (_bucket) {                                                   \ 
    103105            _code                                                           \ 
    104106            _bucket = _bucket->next;                                        \ 
     
    116118        /* If there is no more buckets */                                   \ 
    117119        if ((_loc) == (INTVAL)(_hash)->mask+1)                              \ 
    118120            break;                                                          \ 
    119         (_bucket) = (_hash)->bucket_indices[_loc++];                        \ 
     121        (_bucket) = (_hash)->index[_loc++];                                 \ 
    120122    }                                                                       \ 
    121123} 
    122124 
  • src/hash.c

    diff --git a/src/hash.c b/src/hash.c
    index 968733b..a59b739 100644
    a b  
    800800         | --> buckets |     | 
    801801         +---+---+---+-+-+-+-+ 
    802802         ^             ^ 
    803          | old_mem     | hash->bucket_indices 
     803         | old_mem     | hash->index 
    804804    */ 
    805805 
    806806    /* resize mem */ 
     
    821821         |  buckets  | old_bi    |  new_bi       | 
    822822         +---+---+---+---+---+---+-+-+-+-+-+-+-+-+ 
    823823         ^                       ^ 
    824          | new_mem               | hash->bucket_indices 
     824         | new_mem               | hash->index 
    825825    */ 
    826826 
    827827    bs     = new_mem; 
     
    835835    mem_sys_memmove(new_bi, old_bi, old_size * sizeof (HashBucket *)); 
    836836 
    837837    /* update hash data */ 
    838     hash->bucket_indices = new_bi; 
     838    hash->index = new_bi; 
    839839    hash->buckets        = bs; 
    840840    hash->mask = new_size - 1; 
    841841 
     
    10331033 
    10341034    hash->buckets = bp; 
    10351035    bp += N_BUCKETS(INITIAL_BUCKETS); 
    1036     hash->bucket_indices = (HashBucket **)bp; 
     1036    hash->index = (HashBucket **)bp; 
    10371037 
    10381038    for (i = 0, --bp; i < N_BUCKETS(INITIAL_BUCKETS); ++i, --bp) { 
    10391039        bp->next        = hash->free_list; 
     
    11131113    UINTVAL i; 
    11141114 
    11151115    for (i = 0; i <= hash->mask; ++i) { 
    1116         HashBucket *bucket = hash->bucket_indices[i]; 
     1116        HashBucket *bucket = hash->index[i]; 
    11171117        while (bucket) { 
    11181118            mem_gc_free(interp, bucket->key); 
    11191119            func(bucket->value); 
     
    12381238    /* if the fast search didn't work, try the normal hashing search */ 
    12391239    { 
    12401240        const UINTVAL hashval = get_hash_val(interp, hash, key); 
    1241         HashBucket   *bucket  = hash->bucket_indices[hashval & hash->mask]; 
     1241        HashBucket   *bucket  = hash->index[hashval & hash->mask]; 
    12421242        const hash_comp_fn compare = hash->compare; 
    12431243 
    12441244        while (bucket) { 
     
    13201320{ 
    13211321    ASSERT_ARGS(parrot_hash_put) 
    13221322    const UINTVAL hashval = get_hash_val(interp, hash, key); 
    1323     HashBucket   *bucket  = hash->bucket_indices[hashval & hash->mask]; 
     1323    HashBucket   *bucket  = hash->index[hashval & hash->mask]; 
    13241324    const hash_comp_fn compare = hash->compare; 
    13251325 
    13261326    /* See if we have an existing value for this key */ 
     
    13491349        hash->free_list                = bucket->next; 
    13501350        bucket->key                    = key; 
    13511351        bucket->value                  = value; 
    1352         bucket->next = hash->bucket_indices[hashval & hash->mask]; 
    1353         hash->bucket_indices[hashval & hash->mask] = bucket; 
     1352        bucket->next = hash->index[hashval & hash->mask]; 
     1353        hash->index[hashval & hash->mask] = bucket; 
    13541354    } 
    13551355 
    13561356    return bucket; 
     
    13731373{ 
    13741374    ASSERT_ARGS(parrot_hash_delete) 
    13751375    const UINTVAL hashval = (hash->hash_val)(interp, key, hash->seed) & hash->mask; 
    1376     HashBucket   **prev   = &hash->bucket_indices[hashval]; 
     1376    HashBucket   **prev   = &hash->index[hashval]; 
    13771377    if (*prev) { 
    13781378        const hash_comp_fn compare = hash->compare; 
    13791379        for (; *prev; prev = &(*prev)->next) {