lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [16/22] lucy-clownfish git commit: Make VA_Sort stable
Date Wed, 29 Apr 2015 19:55:17 GMT
Make VA_Sort stable

Switch to mergesort.


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

Branch: refs/heads/master
Commit: 7c88b32d7ee89baddf98edff95831b300a1735a3
Parents: 0e2bdaf
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sun Apr 26 19:21:48 2015 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun Apr 26 21:01:05 2015 +0200

----------------------------------------------------------------------
 runtime/core/Clownfish/VArray.c   | 6 ++++--
 runtime/core/Clownfish/VArray.cfh | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7c88b32d/runtime/core/Clownfish/VArray.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/VArray.c b/runtime/core/Clownfish/VArray.c
index 77e6c46..8343602 100644
--- a/runtime/core/Clownfish/VArray.c
+++ b/runtime/core/Clownfish/VArray.c
@@ -246,8 +246,10 @@ S_default_compare(void *context, const void *va, const void *vb) {
 
 void
 VA_Sort_IMP(VArray *self) {
-    Sort_quicksort(self->elems, self->size, sizeof(void*), S_default_compare,
-                   NULL);
+    void *scratch = MALLOCATE(self->size * sizeof(Obj*));
+    Sort_mergesort(self->elems, scratch, self->size, sizeof(void*),
+                   S_default_compare, NULL);
+    FREEMEM(scratch);
 }
 
 bool

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7c88b32d/runtime/core/Clownfish/VArray.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/VArray.cfh b/runtime/core/Clownfish/VArray.cfh
index 746b05a..27f5e4a 100644
--- a/runtime/core/Clownfish/VArray.cfh
+++ b/runtime/core/Clownfish/VArray.cfh
@@ -96,7 +96,7 @@ class Clownfish::VArray nickname VA inherits Clownfish::Obj {
     public incremented VArray*
     Clone(VArray *self);
 
-    /** Quicksort the VArray.
+    /** Sort the VArray.
      */
     void
     Sort(VArray *self);


Mime
View raw message