Ticket #1741: 0008-Rename-INITIAL_BUCKETS-to-INITIAL_SIZE.patch

File 0008-Rename-INITIAL_BUCKETS-to-INITIAL_SIZE.patch, 2.4 KB (added by luben, 4 years ago)
  • src/hash.c

    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  
    2828 
    2929/* the number of entries above which it's faster to hash the hashval instead of 
    3030 * looping over the used HashBuckets directly */ 
    31 #define INITIAL_BUCKETS  8 
     31#define INITIAL_SIZE  8 
    3232 
    3333/* HEADERIZER HFILE: include/parrot/hash.h */ 
    3434 
     
    10141014    ASSERT_ARGS(parrot_create_hash) 
    10151015    HashBucket  *bp; 
    10161016    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)); 
    10181018    Hash * const hash  = (Hash*)alloc; 
    10191019    size_t       i; 
    10201020 
    1021     PARROT_ASSERT(INITIAL_BUCKETS % 4 == 0); 
     1021    PARROT_ASSERT(INITIAL_SIZE % 4 == 0); 
    10221022 
    10231023    hash->compare    = compare; 
    10241024    hash->hash_val   = keyhash; 
    10251025    hash->entry_type = val_type; 
    10261026    hash->key_type   = hkey_type; 
    10271027    hash->seed       = interp->hash_seed; 
    1028     hash->mask       = INITIAL_BUCKETS - 1; 
     1028    hash->mask       = INITIAL_SIZE - 1; 
    10291029    hash->entries    = 0; 
    10301030    hash->free_list  = NULL; 
    10311031 
    10321032 
    10331033 
    10341034    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)); 
    10361036 
    10371037    /* fill free_list from hi addresses so that we can use 
    10381038     * buckets[i] directly in an OrderedHash, *if* nothing 
    10391039     * was deleted */ 
    10401040 
    1041     bp = (hash->buckets + N_BUCKETS(INITIAL_BUCKETS)); 
     1041    bp = (hash->buckets + N_BUCKETS(INITIAL_SIZE)); 
    10421042 
    1043     for (i = 0, --bp; i < N_BUCKETS(INITIAL_BUCKETS); ++i, --bp) { 
     1043    for (i = 0, --bp; i < N_BUCKETS(INITIAL_SIZE); ++i, --bp) { 
    10441044        bp->next        = hash->free_list; 
    10451045        hash->free_list = bp; 
    10461046    }