4b99ba9 util: hash: Append to hash buckets when adding new entries

Authored and Committed by Peter Krempa 4 years ago
    util: hash: Append to hash buckets when adding new entries
    
    In cases when the hash function for a name collides with other entry
    already in the hash we prepend to the bucket. This creates a 'stack
    effect' on the buckets if we then iterate through the hash. Normally
    this is not a problem, but in tests we want deterministic results.
    
    Since it does not matter where we add the entry and it's usually more
    probable that a different entry will be accessed next change it to
    append to the end of the bucket. Luckily we already iterate throught the
    bucket once thus we can easily find the last entry and just connect the
    new entry after it.
    
    Signed-off-by: Peter Krempa <pkrempa@redhat.com>
    Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
    
        
file modified
+7 -2