You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/04/15 16:05:49 UTC
[2/3] lucy-clownfish git commit: Remove Hash#Make_Key
Remove Hash#Make_Key
This method was only needed for custom Hash keys. Also make Hash_do_store
a static function.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/07bc632d
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/07bc632d
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/07bc632d
Branch: refs/heads/CLOWNFISH-7-string-only-hash-keys
Commit: 07bc632dc1510d57c01dcd8bd88bb42fe14d522c
Parents: 8282412
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Apr 14 13:09:03 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed Apr 15 15:35:26 2015 +0200
----------------------------------------------------------------------
runtime/core/Clownfish/Hash.c | 27 +++++++++------------------
runtime/core/Clownfish/Hash.cfh | 7 -------
2 files changed, 9 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/07bc632d/runtime/core/Clownfish/Hash.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Hash.c b/runtime/core/Clownfish/Hash.c
index 53a2e49..9f6cbe7 100644
--- a/runtime/core/Clownfish/Hash.c
+++ b/runtime/core/Clownfish/Hash.c
@@ -121,9 +121,9 @@ Hash_Clear_IMP(Hash *self) {
self->threshold = (self->capacity / 3) * 2;
}
-void
-Hash_do_store(Hash *self, String *key, Obj *value,
- int32_t hash_sum, bool use_this_key) {
+static void
+S_do_store(Hash *self, String *key, Obj *value, int32_t hash_sum,
+ bool incref_key) {
HashEntry *entry = SI_fetch_entry(self, key, hash_sum);
if (entry) {
DECREF(entry->value);
@@ -145,9 +145,9 @@ Hash_do_store(Hash *self, String *key, Obj *value,
// Take note of diminished tombstone clutter.
self->threshold++;
}
- entry->key = use_this_key
- ? key
- : Hash_Make_Key(self, key, hash_sum);
+ entry->key = incref_key
+ ? (String*)INCREF(key)
+ : key;
entry->value = value;
entry->hash_sum = hash_sum;
self->size++;
@@ -159,21 +159,13 @@ Hash_do_store(Hash *self, String *key, Obj *value,
void
Hash_Store_IMP(Hash *self, String *key, Obj *value) {
- Hash_do_store(self, key, value, Str_Hash_Sum(key), false);
+ S_do_store(self, key, value, Str_Hash_Sum(key), true);
}
void
Hash_Store_Utf8_IMP(Hash *self, const char *key, size_t key_len, Obj *value) {
StackString *key_buf = SSTR_WRAP_UTF8((char*)key, key_len);
- Hash_do_store(self, (String*)key_buf, value,
- SStr_Hash_Sum(key_buf), false);
-}
-
-String*
-Hash_Make_Key_IMP(Hash *self, String *key, int32_t hash_sum) {
- UNUSED_VAR(self);
- UNUSED_VAR(hash_sum);
- return Str_Clone(key);
+ S_do_store(self, (String*)key_buf, value, SStr_Hash_Sum(key_buf), true);
}
Obj*
@@ -347,8 +339,7 @@ SI_rebuild_hash(Hash *self) {
if (!entry->key || entry->key == TOMBSTONE) {
continue;
}
- Hash_do_store(self, entry->key, entry->value,
- entry->hash_sum, true);
+ S_do_store(self, entry->key, entry->value, entry->hash_sum, false);
}
FREEMEM(old_entries);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/07bc632d/runtime/core/Clownfish/Hash.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Hash.cfh b/runtime/core/Clownfish/Hash.cfh
index c33b010..32cfb97 100644
--- a/runtime/core/Clownfish/Hash.cfh
+++ b/runtime/core/Clownfish/Hash.cfh
@@ -112,13 +112,6 @@ class Clownfish::Hash inherits Clownfish::Obj {
incremented VArray*
Values(Hash *self);
- /** Create a key to be stored within the hash entry. Implementations must
- * supply an object which produces the same [](cfish:Obj.Hash_Sum) value and tests
- * true for [](cfish:Obj.Equals). By default, calls [](cfish:Obj.Clone).
- */
- public incremented String*
- Make_Key(Hash *self, String *key, int32_t hash_sum);
-
uint32_t
Get_Capacity(Hash *self);