Repository: lucy-clownfish Updated Branches: refs/heads/master 9fea2c92c -> 5bed14937
Remove Obj#Hash_Sum Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/5bed1493 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/5bed1493 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/5bed1493 Branch: refs/heads/master Commit: 5bed14937bf3a8cdfde8e9b805f6ff9fe2931850 Parents: 9fea2c9 Author: Nick Wellnhofer <[email protected]> Authored: Mon Apr 20 16:44:04 2015 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Mon Apr 20 16:54:17 2015 +0200 ---------------------------------------------------------------------- runtime/core/Clownfish/ByteBuf.c | 12 --------- runtime/core/Clownfish/ByteBuf.cfh | 3 --- runtime/core/Clownfish/Num.c | 28 -------------------- runtime/core/Clownfish/Num.cfh | 15 ----------- runtime/core/Clownfish/Obj.c | 6 ----- runtime/core/Clownfish/Obj.cfh | 5 ---- runtime/core/Clownfish/String.cfh | 4 ++- runtime/core/Clownfish/Test/TestByteBuf.c | 5 +--- .../Clownfish/Test/TestLockFreeRegistry.cfh | 2 +- runtime/core/Clownfish/Test/TestObj.c | 13 +-------- 10 files changed, 6 insertions(+), 87 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5bed1493/runtime/core/Clownfish/ByteBuf.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/ByteBuf.c b/runtime/core/Clownfish/ByteBuf.c index d1845b8..6287552 100644 --- a/runtime/core/Clownfish/ByteBuf.c +++ b/runtime/core/Clownfish/ByteBuf.c @@ -125,18 +125,6 @@ BB_Equals_Bytes_IMP(ByteBuf *self, const void *bytes, size_t size) { return SI_equals_bytes(self, bytes, size); } -int32_t -BB_Hash_Sum_IMP(ByteBuf *self) { - uint32_t sum = 5381; - uint8_t *const buf = (uint8_t*)self->buf; - - for (size_t i = 0, max = self->size; i < max; i++) { - sum = ((sum << 5) + sum) ^ buf[i]; - } - - return (int32_t)sum; -} - static CFISH_INLINE void SI_mimic_bytes(ByteBuf *self, const void *bytes, size_t size) { if (size > self->cap) { S_grow(self, size); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5bed1493/runtime/core/Clownfish/ByteBuf.cfh ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/ByteBuf.cfh b/runtime/core/Clownfish/ByteBuf.cfh index 01869e7..b44703a 100644 --- a/runtime/core/Clownfish/ByteBuf.cfh +++ b/runtime/core/Clownfish/ByteBuf.cfh @@ -122,9 +122,6 @@ class Clownfish::ByteBuf nickname BB inherits Clownfish::Obj { public bool Equals(ByteBuf *self, Obj *other); - - public int32_t - Hash_Sum(ByteBuf *self); } /** http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5bed1493/runtime/core/Clownfish/Num.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Num.c b/runtime/core/Clownfish/Num.c index 895be7e..862156c 100644 --- a/runtime/core/Clownfish/Num.c +++ b/runtime/core/Clownfish/Num.c @@ -128,11 +128,6 @@ Float32_To_I64_IMP(Float32 *self) { return (int64_t)self->value; } -int32_t -Float32_Hash_Sum_IMP(Float32 *self) { - return *(int32_t*)&self->value; -} - Float32* Float32_Clone_IMP(Float32 *self) { return Float32_new(self->value); @@ -189,12 +184,6 @@ Float64_Mimic_IMP(Float64 *self, Obj *other) { self->value = twin->value; } -int32_t -Float64_Hash_Sum_IMP(Float64 *self) { - int32_t *ints = (int32_t*)&self->value; - return ints[0] ^ ints[1]; -} - /***************************************************************************/ Integer32* @@ -240,11 +229,6 @@ Int32_Mimic_IMP(Integer32 *self, Obj *other) { self->value = twin->value; } -int32_t -Int32_Hash_Sum_IMP(Integer32 *self) { - return self->value; -} - /***************************************************************************/ Integer64* @@ -290,12 +274,6 @@ Int64_Mimic_IMP(Integer64 *self, Obj *other) { self->value = twin->value; } -int32_t -Int64_Hash_Sum_IMP(Integer64 *self) { - int32_t *ints = (int32_t*)&self->value; - return ints[0] ^ ints[1]; -} - bool Int64_Equals_IMP(Integer64 *self, Obj *other) { Num *twin = (Num*)other; @@ -366,12 +344,6 @@ Bool_Clone_IMP(BoolNum *self) { return self; } -int32_t -Bool_Hash_Sum_IMP(BoolNum *self) { - int64_t hash_sum = CHY_PTR_TO_I64(self) + self->value; - return (int32_t)hash_sum; -} - String* Bool_To_String_IMP(BoolNum *self) { return (String*)INCREF(self->string); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5bed1493/runtime/core/Clownfish/Num.cfh ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Num.cfh b/runtime/core/Clownfish/Num.cfh index 788a0bc..f52ed18 100644 --- a/runtime/core/Clownfish/Num.cfh +++ b/runtime/core/Clownfish/Num.cfh @@ -83,9 +83,6 @@ class Clownfish::Float32 inherits Clownfish::FloatNum { public double To_F64(Float32 *self); - public int32_t - Hash_Sum(Float32 *self); - public incremented Float32* Clone(Float32 *self); @@ -120,9 +117,6 @@ class Clownfish::Float64 inherits Clownfish::FloatNum { public double To_F64(Float64 *self); - public int32_t - Hash_Sum(Float64 *self); - public incremented Float64* Clone(Float64 *self); @@ -158,9 +152,6 @@ class Clownfish::Integer32 nickname Int32 public double To_F64(Integer32 *self); - public int32_t - Hash_Sum(Integer32 *self); - public incremented Integer32* Clone(Integer32 *self); @@ -197,9 +188,6 @@ class Clownfish::Integer64 nickname Int64 public double To_F64(Integer64 *self); - public int32_t - Hash_Sum(Integer64 *self); - public bool Equals(Integer64 *self, Obj *other); @@ -248,9 +236,6 @@ class Clownfish::BoolNum nickname Bool inherits Clownfish::IntNum { public bool To_Bool(BoolNum *self); - public int32_t - Hash_Sum(BoolNum *self); - /* Returns self. */ public incremented BoolNum* Clone(BoolNum *self); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5bed1493/runtime/core/Clownfish/Obj.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Obj.c b/runtime/core/Clownfish/Obj.c index 69320fd..3e2d040 100644 --- a/runtime/core/Clownfish/Obj.c +++ b/runtime/core/Clownfish/Obj.c @@ -42,12 +42,6 @@ Obj_Destroy_IMP(Obj *self) { FREEMEM(self); } -int32_t -Obj_Hash_Sum_IMP(Obj *self) { - int64_t hash_sum = CHY_PTR_TO_I64(self); - return (int32_t)hash_sum; -} - bool Obj_Is_A_IMP(Obj *self, Class *ancestor) { Class *klass = self ? self->klass : NULL; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5bed1493/runtime/core/Clownfish/Obj.cfh ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Obj.cfh b/runtime/core/Clownfish/Obj.cfh index 44e9713..9e74467 100644 --- a/runtime/core/Clownfish/Obj.cfh +++ b/runtime/core/Clownfish/Obj.cfh @@ -63,11 +63,6 @@ public abstract class Clownfish::Obj { public abstract int32_t Compare_To(Obj *self, Obj *other); - /** Return a hash code for the object -- by default, the memory address. - */ - public int32_t - Hash_Sum(Obj *self); - /** Return the object's Class. */ public Class* http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5bed1493/runtime/core/Clownfish/String.cfh ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/String.cfh b/runtime/core/Clownfish/String.cfh index 8fe7cc5..5c0fb72 100644 --- a/runtime/core/Clownfish/String.cfh +++ b/runtime/core/Clownfish/String.cfh @@ -215,7 +215,9 @@ class Clownfish::String nickname Str public int32_t Compare_To(String *self, Obj *other); - public int32_t + /** Return a hash code for the string. + */ + int32_t Hash_Sum(String *self); public incremented String* http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5bed1493/runtime/core/Clownfish/Test/TestByteBuf.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test/TestByteBuf.c b/runtime/core/Clownfish/Test/TestByteBuf.c index 3aba1f1..c393450 100644 --- a/runtime/core/Clownfish/Test/TestByteBuf.c +++ b/runtime/core/Clownfish/Test/TestByteBuf.c @@ -38,7 +38,6 @@ test_Equals(TestBatchRunner *runner) { ByteBuf *got = BB_new_bytes("foo", 4); TEST_TRUE(runner, BB_Equals(wanted, (Obj*)got), "Equals"); - TEST_INT_EQ(runner, BB_Hash_Sum(got), BB_Hash_Sum(wanted), "Hash_Sum"); TEST_TRUE(runner, BB_Equals_Bytes(got, "foo", 4), "Equals_Bytes"); TEST_FALSE(runner, BB_Equals_Bytes(got, "foo", 3), @@ -49,8 +48,6 @@ test_Equals(TestBatchRunner *runner) { BB_Set_Size(got, 3); TEST_FALSE(runner, BB_Equals(wanted, (Obj*)got), "Different size spoils Equals"); - TEST_FALSE(runner, BB_Hash_Sum(got) == BB_Hash_Sum(wanted), - "Different size spoils Hash_Sum (probably -- at least this one)"); BB_Mimic_Bytes(got, "bar", 4); TEST_INT_EQ(runner, BB_Get_Size(wanted), BB_Get_Size(got), @@ -144,7 +141,7 @@ test_Cat(TestBatchRunner *runner) { void TestBB_Run_IMP(TestByteBuf *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 21); + TestBatchRunner_Plan(runner, (TestBatch*)self, 19); test_Equals(runner); test_Grow(runner); test_Clone(runner); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5bed1493/runtime/core/Clownfish/Test/TestLockFreeRegistry.cfh ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test/TestLockFreeRegistry.cfh b/runtime/core/Clownfish/Test/TestLockFreeRegistry.cfh index d7049c8..a54f00b 100644 --- a/runtime/core/Clownfish/Test/TestLockFreeRegistry.cfh +++ b/runtime/core/Clownfish/Test/TestLockFreeRegistry.cfh @@ -33,7 +33,7 @@ class Clownfish::Test::StupidHashString inherits Clownfish::String { new(const char *text); /** Always returns 1, guaranteeing collisions. */ - public int32_t + int32_t Hash_Sum(StupidHashString *self); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5bed1493/runtime/core/Clownfish/Test/TestObj.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test/TestObj.c b/runtime/core/Clownfish/Test/TestObj.c index e0bcf6a..a930249 100644 --- a/runtime/core/Clownfish/Test/TestObj.c +++ b/runtime/core/Clownfish/Test/TestObj.c @@ -86,16 +86,6 @@ test_Equals(TestBatchRunner *runner) { } static void -test_Hash_Sum(TestBatchRunner *runner) { - Obj *testobj = S_new_testobj(); - int64_t address64 = CHY_PTR_TO_I64(testobj); - int32_t address32 = (int32_t)address64; - TEST_TRUE(runner, (Obj_Hash_Sum(testobj) == address32), - "Hash_Sum uses memory address"); - DECREF(testobj); -} - -static void test_Is_A(TestBatchRunner *runner) { String *string = Str_new_from_trusted_utf8("", 0); Class *str_class = Str_Get_Class(string); @@ -169,11 +159,10 @@ test_abstract_routines(TestBatchRunner *runner) { void TestObj_Run_IMP(TestObj *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 17); + TestBatchRunner_Plan(runner, (TestBatch*)self, 16); test_refcounts(runner); test_To_String(runner); test_Equals(runner); - test_Hash_Sum(runner); test_Is_A(runner); test_abstract_routines(runner); }
