summaryrefslogtreecommitdiff
path: root/mysys/hash.c
diff options
context:
space:
mode:
authorMikael Ronstrom <mikael@mysql.com>2009-10-09 14:22:22 +0200
committerMikael Ronstrom <mikael@mysql.com>2009-10-09 14:22:22 +0200
commitd3540b216f2d39126d77985db3f7639eb45bf967 (patch)
treebd91284ce826b8e44b1a50008e69d8dc56a5d5a1 /mysys/hash.c
parentee696e4163354b85c60c68cb791005fa127abcea (diff)
downloadmariadb-git-d3540b216f2d39126d77985db3f7639eb45bf967.tar.gz
A minor change to MySQL's hash where calculation of hash can be done separately to avoid doing it under contended mutex locks
Diffstat (limited to 'mysys/hash.c')
-rw-r--r--mysys/hash.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/mysys/hash.c b/mysys/hash.c
index 63933abb085..367ac8713dd 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -214,6 +214,20 @@ uchar* my_hash_search(const HASH *hash, const uchar *key, size_t length)
return my_hash_first(hash, key, length, &state);
}
+uchar* my_hash_search_using_hash_value(const HASH *hash,
+ uint hash_value,
+ const uchar *key,
+ size_t length)
+{
+ HASH_SEARCH_STATE state;
+ return my_hash_first_from_hash_value(hash, hash_value,
+ key, length, &state);
+}
+
+uint my_calc_hash(const HASH *hash, const uchar *key, size_t length)
+{
+ return calc_hash(hash, key, length ? length : hash->key_length);
+}
/*
Search after a record based on a key
@@ -224,14 +238,25 @@ uchar* my_hash_search(const HASH *hash, const uchar *key, size_t length)
uchar* my_hash_first(const HASH *hash, const uchar *key, size_t length,
HASH_SEARCH_STATE *current_record)
{
+ return my_hash_first_from_hash_value(hash,
+ calc_hash(hash, key, length ? length : hash->key_length),
+ key, length, current_record);
+}
+
+uchar* my_hash_first_from_hash_value(const HASH *hash,
+ uint hash_value,
+ const uchar *key,
+ size_t length,
+ HASH_SEARCH_STATE *current_record)
+{
HASH_LINK *pos;
uint flag,idx;
- DBUG_ENTER("my_hash_first");
+ DBUG_ENTER("my_hash_first_from_hash_value");
flag=1;
if (hash->records)
{
- idx= my_hash_mask(calc_hash(hash, key, length ? length : hash->key_length),
+ idx= my_hash_mask(hash_value,
hash->blength, hash->records);
do
{