lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [02/22] lucy-clownfish git commit: Remove support for custom array sort
Date Wed, 29 Apr 2015 19:55:03 GMT
Remove support for custom array sort


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/54c42e44
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/54c42e44
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/54c42e44

Branch: refs/heads/master
Commit: 54c42e44ddb11f7730b05fda6e5ce93c26e17fa1
Parents: a75e2bc
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sun Apr 26 14:03:20 2015 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun Apr 26 19:39:58 2015 +0200

----------------------------------------------------------------------
 runtime/core/Clownfish/Test/TestHash.c         | 12 ++++----
 runtime/core/Clownfish/Test/TestHashIterator.c |  6 ++--
 runtime/core/Clownfish/Test/TestVArray.c       | 31 ++-------------------
 runtime/core/Clownfish/VArray.c                |  6 ++--
 runtime/core/Clownfish/VArray.cfh              | 12 ++------
 5 files changed, 16 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/54c42e44/runtime/core/Clownfish/Test/TestHash.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestHash.c b/runtime/core/Clownfish/Test/TestHash.c
index bc006d9..f871641 100644
--- a/runtime/core/Clownfish/Test/TestHash.c
+++ b/runtime/core/Clownfish/Test/TestHash.c
@@ -141,12 +141,12 @@ test_Keys_Values(TestBatchRunner *runner) {
         VA_Push(expected, INCREF(str));
     }
 
-    VA_Sort(expected, NULL, NULL);
+    VA_Sort(expected);
 
     keys   = Hash_Keys(hash);
     values = Hash_Values(hash);
-    VA_Sort(keys, NULL, NULL);
-    VA_Sort(values, NULL, NULL);
+    VA_Sort(keys);
+    VA_Sort(values);
     TEST_TRUE(runner, VA_Equals(keys, (Obj*)expected), "Keys");
     TEST_TRUE(runner, VA_Equals(values, (Obj*)expected), "Values");
     VA_Clear(keys);
@@ -185,7 +185,7 @@ test_stress(TestBatchRunner *runner) {
         VA_Push(expected, INCREF(str));
     }
 
-    VA_Sort(expected, NULL, NULL);
+    VA_Sort(expected);
 
     // Overwrite for good measure.
     for (uint32_t i = 0; i < 1000; i++) {
@@ -195,8 +195,8 @@ test_stress(TestBatchRunner *runner) {
 
     keys   = Hash_Keys(hash);
     values = Hash_Values(hash);
-    VA_Sort(keys, NULL, NULL);
-    VA_Sort(values, NULL, NULL);
+    VA_Sort(keys);
+    VA_Sort(values);
     TEST_TRUE(runner, VA_Equals(keys, (Obj*)expected), "stress Keys");
     TEST_TRUE(runner, VA_Equals(values, (Obj*)expected), "stress Values");
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/54c42e44/runtime/core/Clownfish/Test/TestHashIterator.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestHashIterator.c b/runtime/core/Clownfish/Test/TestHashIterator.c
index 98c9ebf..87f9f6f 100644
--- a/runtime/core/Clownfish/Test/TestHashIterator.c
+++ b/runtime/core/Clownfish/Test/TestHashIterator.c
@@ -50,7 +50,7 @@ test_Next(TestBatchRunner *runner) {
         VA_Push(expected, INCREF(str));
     }
 
-    VA_Sort(expected, NULL, NULL);
+    VA_Sort(expected);
 
     {
         HashIterator *iter = HashIter_new(hash);
@@ -66,8 +66,8 @@ test_Next(TestBatchRunner *runner) {
         DECREF(iter);
     }
 
-    VA_Sort(keys, NULL, NULL);
-    VA_Sort(values, NULL, NULL);
+    VA_Sort(keys);
+    VA_Sort(values);
     TEST_TRUE(runner, VA_Equals(keys, (Obj*)expected), "Keys from Iter");
     TEST_TRUE(runner, VA_Equals(values, (Obj*)expected), "Values from Iter");
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/54c42e44/runtime/core/Clownfish/Test/TestVArray.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestVArray.c b/runtime/core/Clownfish/Test/TestVArray.c
index bbe4573..03aaf60 100644
--- a/runtime/core/Clownfish/Test/TestVArray.c
+++ b/runtime/core/Clownfish/Test/TestVArray.c
@@ -425,29 +425,6 @@ test_exceptions(TestBatchRunner *runner) {
                      "Store throws on overflow");
 }
 
-static int
-S_reverse_compare(void *context, const void *va, const void *vb) {
-    Obj *a = *(Obj**)va;
-    Obj *b = *(Obj**)vb;
-    UNUSED_VAR(context);
-    if (a != NULL && b != NULL)      { return -Obj_Compare_To(a, b); }
-    else if (a == NULL && b == NULL) { return 0;  }
-    else if (a == NULL)              { return -1; } // NULL to the front
-    else  /* b == NULL */            { return 1;  } // NULL to the front
-}
-
-static void
-S_reverse_array(VArray *array) {
-    uint32_t size = VA_Get_Size(array);
-
-    for (uint32_t l = 0, r = size - 1; l < r; ++l, --r) {
-        Obj *left  = VA_Delete(array, l);
-        Obj *right = VA_Delete(array, r);
-        VA_Store(array, l, right);
-        VA_Store(array, r, left);
-    }
-}
-
 static void
 test_Sort(TestBatchRunner *runner) {
     VArray *array  = VA_new(8);
@@ -469,13 +446,9 @@ test_Sort(TestBatchRunner *runner) {
     VA_Push(wanted, NULL);
     VA_Push(wanted, NULL);
 
-    VA_Sort(array, NULL, NULL);
+    VA_Sort(array);
     TEST_TRUE(runner, VA_Equals(array, (Obj*)wanted), "Sort with NULLs");
 
-    VA_Sort(array, S_reverse_compare, NULL);
-    S_reverse_array(wanted);
-    TEST_TRUE(runner, VA_Equals(array, (Obj*)wanted), "Custom Sort");
-
     DECREF(array);
     DECREF(wanted);
 }
@@ -544,7 +517,7 @@ test_Grow(TestBatchRunner *runner) {
 
 void
 TestVArray_Run_IMP(TestVArray *self, TestBatchRunner *runner) {
-    TestBatchRunner_Plan(runner, (TestBatch*)self, 63);
+    TestBatchRunner_Plan(runner, (TestBatch*)self, 62);
     test_Equals(runner);
     test_Store_Fetch(runner);
     test_Push_Pop_Insert(runner);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/54c42e44/runtime/core/Clownfish/VArray.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/VArray.c b/runtime/core/Clownfish/VArray.c
index 312e52e..b5e9fc5 100644
--- a/runtime/core/Clownfish/VArray.c
+++ b/runtime/core/Clownfish/VArray.c
@@ -253,9 +253,9 @@ S_default_compare(void *context, const void *va, const void *vb) {
 }
 
 void
-VA_Sort_IMP(VArray *self, CFISH_Sort_Compare_t compare, void *context) {
-    if (!compare) { compare = S_default_compare; }
-    Sort_quicksort(self->elems, self->size, sizeof(void*), compare, context);
+VA_Sort_IMP(VArray *self) {
+    Sort_quicksort(self->elems, self->size, sizeof(void*), S_default_compare,
+                   NULL);
 }
 
 bool

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/54c42e44/runtime/core/Clownfish/VArray.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/VArray.cfh b/runtime/core/Clownfish/VArray.cfh
index 893132c..807067c 100644
--- a/runtime/core/Clownfish/VArray.cfh
+++ b/runtime/core/Clownfish/VArray.cfh
@@ -17,8 +17,6 @@
 parcel Clownfish;
 
 __C__
-#include "Clownfish/Util/SortUtils.h"
-
 typedef bool
 (*CFISH_VA_Gather_Test_t)(cfish_VArray *self, size_t tick, void *data);
 
@@ -112,16 +110,10 @@ class Clownfish::VArray nickname VA inherits Clownfish::Obj {
     public incremented VArray*
     Clone(VArray *self);
 
-    /** Quicksort the VArry using the supplied comparison routine.  Safety
-     * checks are the responsibility of the caller.
-     *
-     * @param compare Comparison routine.  The default uses Obj_Compare_To and
-     * sorts NULL elements towards the end.
-     * @param context Argument supplied to the comparison routine.
+    /** Quicksort the VArray.
      */
     void
-    Sort(VArray *self, CFISH_Sort_Compare_t compare = NULL,
-         void *context = NULL);
+    Sort(VArray *self);
 
     /** Set the size for the VArray.  If the new size is larger than the
      * current size, grow the object to accommodate NULL elements; if smaller


Mime
View raw message