]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: hash: Append to hash buckets when adding new entries
authorPeter Krempa <pkrempa@redhat.com>
Tue, 16 Apr 2019 13:11:40 +0000 (15:11 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 25 Apr 2019 11:28:16 +0000 (13:28 +0200)
commit4b99ba98d094a4b20ac20100ccbeab3a6b88a3e1
tree716495dfe5ca3a22e30ab7c8d5c9a99e79aac225
parentcc1d1dbbd5fa18876a5ca8ac99a991b32ad49409
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>
src/util/virhash.c