compare hash value before call compare_fct()
authorLai Jiangshan <laijs@cn.fujitsu.com>
Mon, 17 Oct 2011 14:26:58 +0000 (10:26 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 17 Oct 2011 14:26:58 +0000 (10:26 -0400)
[ Edit by Mathieu Desnoyers:

  This is an optimisation that checks if the reverse hash value is
  equal before calling the comparison function. Given comparing a
  reverse hash is much faster than comparison, this accelarates the
  lookups and add. ]

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rculfhash.c

index 189f8c831237edfe205c6461babadb765b537285..6e07878a1c3db3c2afac4700727491a2aa8be3ea 100644 (file)
@@ -892,6 +892,7 @@ struct cds_lfht_node *_cds_lfht_add(struct cds_lfht *ht,
                                goto gc_node;
                        if ((mode == ADD_UNIQUE || mode == ADD_REPLACE)
                            && !is_dummy(next)
+                           && clear_flag(iter)->p.reverse_hash == node->p.reverse_hash
                            && !ht->compare_fct(node->key, node->key_len,
                                                clear_flag(iter)->key,
                                                clear_flag(iter)->key_len)) {
@@ -1341,6 +1342,7 @@ void cds_lfht_lookup(struct cds_lfht *ht, void *key, size_t key_len,
                next = rcu_dereference(node->p.next);
                if (likely(!is_removed(next))
                    && !is_dummy(next)
+                   && clear_flag(node)->p.reverse_hash == reverse_hash
                    && likely(!ht->compare_fct(node->key, node->key_len, key, key_len))) {
                                break;
                }
This page took 0.025992 seconds and 4 git commands to generate.