Remove Str_compare and Str_less_than

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

Branch: refs/heads/master
Commit: 8b5f8dbe7934c5f22372573b11acb75255541661
Parents: 77d6dfd
Author: Nick Wellnhofer <wellnho...@aevum.de>
Authored: Thu Oct 22 15:52:10 2015 +0200
Committer: Nick Wellnhofer <wellnho...@aevum.de>
Committed: Wed Oct 28 15:35:18 2015 +0100

----------------------------------------------------------------------
 runtime/core/Clownfish/String.c   | 48 +++++++++++++---------------------
 runtime/core/Clownfish/String.cfh | 13 ---------
 2 files changed, 18 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8b5f8dbe/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/String.c b/runtime/core/Clownfish/String.c
index 7d0b871..3afbdc1 100644
--- a/runtime/core/Clownfish/String.c
+++ b/runtime/core/Clownfish/String.c
@@ -343,8 +343,24 @@ Str_Equals_IMP(String *self, Obj *other) {
 
 int32_t
 Str_Compare_To_IMP(String *self, Obj *other) {
-    CERTIFY(other, STRING);
-    return Str_compare(&self, &other);
+    String  *twin = (String*)CERTIFY(other, STRING);
+    size_t   min_size;
+    int32_t  tie;
+
+    if (self->size <= twin->size) {
+        min_size = self->size;
+        tie      = self->size < twin->size ? -1 : 0;
+    }
+    else {
+        min_size = twin->size;
+        tie      = 1;
+    }
+
+    int comparison = memcmp(self->ptr, twin->ptr, min_size);
+    if (comparison < 0) { return -1; }
+    if (comparison > 0) { return 1; }
+
+    return tie;
 }
 
 bool
@@ -457,34 +473,6 @@ Str_SubString_IMP(String *self, size_t offset, size_t len) 
{
     return S_new_substring(self, start_offset, size);
 }
 
-int
-Str_compare(const void *va, const void *vb) {
-    String *a = *(String**)va;
-    String *b = *(String**)vb;
-    size_t min_size;
-    int    tie;
-
-    if (a->size <= b->size) {
-        min_size = a->size;
-        tie      = a->size < b->size ? -1 : 0;
-    }
-    else {
-        min_size = b->size;
-        tie      = 1;
-    }
-
-    int comparison = memcmp(a->ptr, b->ptr, min_size);
-    if (comparison < 0) { return -1; }
-    if (comparison > 0) { return 1; }
-
-    return tie;
-}
-
-bool
-Str_less_than(const void *va, const void *vb) {
-    return Str_compare(va, vb) < 0 ? true : false;
-}
-
 size_t
 Str_Get_Size_IMP(String *self) {
     return self->size;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8b5f8dbe/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/String.cfh 
b/runtime/core/Clownfish/String.cfh
index 9501970..cc29b2e 100644
--- a/runtime/core/Clownfish/String.cfh
+++ b/runtime/core/Clownfish/String.cfh
@@ -107,19 +107,6 @@ public final class Clownfish::String nickname Str
     inert incremented String*
     newf(const char *pattern, ...);
 
-    /** Perform lexical comparison of two Strings, with level of indirection
-     * set to please qsort and friends.
-     */
-    inert int
-    compare(const void *va, const void *vb);
-
-    /** Perform lexical comparison of two Strings, with level of indirection
-     * set to please qsort and friends, and return true if `a` is
-     * less than `b`.
-     */
-    inert bool
-    less_than(const void *va, const void *vb);
-
     void*
     To_Host(String *self);
 

Reply via email to