1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
From 96bc63757121361c4d7904b1664936f8f2426882 Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@gnupg.org>
Date: Sat, 30 Apr 2016 00:19:41 +0200
Subject: [PATCH hurd 2/2] libihash: enable fast insertions replacing
tombstones
* libihash/ihash.c (hurd_ihash_locp_add): Also replace tombstones.
---
libihash/ihash.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/libihash/ihash.c b/libihash/ihash.c
index c6143a5..2fc7093 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
{
--
2.1.4
|