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 2014/08/03 17:47:10 UTC
[3/9] git commit: Special case String hash keys
Special case String hash keys
For immutable strings, it's enough to incref the hash key.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/a081f6b5
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/a081f6b5
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/a081f6b5
Branch: refs/heads/clone_class_registry
Commit: a081f6b590653b3e3fc3ca5cba1d4cc356c426a9
Parents: a360af7
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Aug 3 14:11:46 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sun Aug 3 17:38:04 2014 +0200
----------------------------------------------------------------------
runtime/core/Clownfish/Hash.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a081f6b5/runtime/core/Clownfish/Hash.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Hash.c b/runtime/core/Clownfish/Hash.c
index 987631c..70181c0 100644
--- a/runtime/core/Clownfish/Hash.c
+++ b/runtime/core/Clownfish/Hash.c
@@ -16,6 +16,7 @@
#define C_CFISH_HASH
#define C_CFISH_HASHTOMBSTONE
+#define C_CFISH_OBJ
#define CFISH_USE_SHORT_NAMES
#include <string.h>
@@ -166,7 +167,13 @@ Obj*
Hash_Make_Key_IMP(Hash *self, Obj *key, int32_t hash_sum) {
UNUSED_VAR(self);
UNUSED_VAR(hash_sum);
- return Obj_Clone(key);
+ if (key->klass == STRING || key->klass == STACKSTRING) {
+ // Strings are immutable.
+ return INCREF(key);
+ }
+ else {
+ return Obj_Clone(key);
+ }
}
Obj*