summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-04-30 00:19:41 +0200
committerJustus Winter <justus@gnupg.org>2016-05-03 17:19:50 +0200
commit736fa7a565e28425220be797235913d0f7b96acd (patch)
tree186a191999d74a7f9352abc98cc22df67ab50623
parent8d4db629aa10189d3a545ec1639105cfb9bae650 (diff)
libihash: enable fast insertions replacing tombstones
* libihash/ihash.c (hurd_ihash_locp_add): Also replace tombstones.
-rw-r--r--libihash/ihash.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libihash/ihash.c b/libihash/ihash.c
index c6143a57..2fc70930 100644
--- a/libihash/ihash.c
+++ b/libihash/ihash.c
@@ -287,17 +287,20 @@ hurd_ihash_locp_add (hurd_ihash_t ht, hurd_ihash_locp_t locp,
/* In case of complications, fall back to hurd_ihash_add. */
if (ht->size == 0
|| item == NULL
- || item->value == _HURD_IHASH_DELETED
- || ! compare (ht, item->key, key)
+ || (hurd_ihash_value_valid (item->value)
+ && ! compare (ht, item->key, key))
|| hurd_ihash_get_effective_load (ht) > ht->max_load)
return hurd_ihash_add (ht, key, value);
- if (item->value == _HURD_IHASH_EMPTY)
+ if (! hurd_ihash_value_valid (item->value))
{
item->key = key;
ht->nr_items += 1;
- assert (ht->nr_free > 0);
- ht->nr_free -= 1;
+ if (item->value == _HURD_IHASH_EMPTY)
+ {
+ assert (ht->nr_free > 0);
+ ht->nr_free -= 1;
+ }
}
else
{