lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [05/15] lucy-clownfish git commit: Remove Str_Swap_Chars
Date Fri, 30 Oct 2015 14:30:40 GMT
Remove Str_Swap_Chars

Only used once in Lucy. A method to replace whole strings would be more
useful.


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

Branch: refs/heads/master
Commit: 0bfc3498832d06468a337fe554de52ab631ebf6e
Parents: f097093
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Thu Oct 22 15:36:53 2015 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Wed Oct 28 15:35:18 2015 +0100

----------------------------------------------------------------------
 runtime/core/Clownfish/String.c          | 16 ----------------
 runtime/core/Clownfish/String.cfh        |  7 -------
 runtime/core/Clownfish/Test/TestString.c | 14 +-------------
 runtime/go/build.go                      |  1 -
 runtime/go/clownfish/clownfish.go        |  7 -------
 runtime/go/clownfish/string_test.go      |  8 --------
 6 files changed, 1 insertion(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0bfc3498/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/String.c b/runtime/core/Clownfish/String.c
index 3124be5..dd6d5dd 100644
--- a/runtime/core/Clownfish/String.c
+++ b/runtime/core/Clownfish/String.c
@@ -219,22 +219,6 @@ Str_To_String_IMP(String *self) {
     return (String*)INCREF(self);
 }
 
-String*
-Str_Swap_Chars_IMP(String *self, int32_t match, int32_t replacement) {
-    CharBuf *charbuf = CB_new(self->size);
-    StringIterator *iter = STACK_ITER(self, 0);
-    int32_t code_point;
-
-    while (STRITER_DONE != (code_point = StrIter_Next(iter))) {
-        if (code_point == match) { code_point = replacement; }
-        CB_Cat_Char(charbuf, code_point);
-    }
-
-    String *retval = CB_Yield_String(charbuf);
-    DECREF(charbuf);
-    return retval;
-}
-
 int64_t
 Str_To_I64_IMP(String *self) {
     return Str_BaseX_To_I64(self, 10);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0bfc3498/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/String.cfh b/runtime/core/Clownfish/String.cfh
index 98b341f..55b56a4 100644
--- a/runtime/core/Clownfish/String.cfh
+++ b/runtime/core/Clownfish/String.cfh
@@ -140,13 +140,6 @@ public final class Clownfish::String nickname Str
     incremented String*
     Cat_Trusted_Utf8(String *self, const char *ptr, size_t size);
 
-    /** Replace all instances of one character for the other.
-     *
-     * @return a new String with the characters replaced.
-     */
-    incremented String*
-    Swap_Chars(String *self, int32_t match, int32_t replacement);
-
     public int64_t
     To_I64(String *self);
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0bfc3498/runtime/core/Clownfish/Test/TestString.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestString.c b/runtime/core/Clownfish/Test/TestString.c
index d305a00..d3cc38c 100644
--- a/runtime/core/Clownfish/Test/TestString.c
+++ b/runtime/core/Clownfish/Test/TestString.c
@@ -386,17 +386,6 @@ test_Compare_To(TestBatchRunner *runner) {
 }
 
 static void
-test_Swap_Chars(TestBatchRunner *runner) {
-    String *source = S_get_str("aXXbXc");
-    String *got    = Str_Swap_Chars(source, 'X', smiley_cp);
-    String *wanted = Str_newf("a%s%sb%sc", smiley, smiley, smiley);
-    TEST_TRUE(runner, Str_Equals(got, (Obj*)wanted), "Swap_Chars");
-    DECREF(wanted);
-    DECREF(got);
-    DECREF(source);
-}
-
-static void
 test_Starts_Ends_With(TestBatchRunner *runner) {
     String *prefix  = S_get_str("pre" SMILEY "fix_");
     String *postfix = S_get_str("_post" SMILEY "fix");
@@ -687,7 +676,7 @@ test_iterator_substring(TestBatchRunner *runner) {
 
 void
 TestStr_Run_IMP(TestString *self, TestBatchRunner *runner) {
-    TestBatchRunner_Plan(runner, (TestBatch*)self, 134);
+    TestBatchRunner_Plan(runner, (TestBatch*)self, 133);
     test_new(runner);
     test_Cat(runner);
     test_Clone(runner);
@@ -701,7 +690,6 @@ TestStr_Run_IMP(TestString *self, TestBatchRunner *runner) {
     test_To_Utf8(runner);
     test_Length(runner);
     test_Compare_To(runner);
-    test_Swap_Chars(runner);
     test_Starts_Ends_With(runner);
     test_Get_Ptr8(runner);
     test_iterator(runner);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0bfc3498/runtime/go/build.go
----------------------------------------------------------------------
diff --git a/runtime/go/build.go b/runtime/go/build.go
index abc57a8..6b0b0be 100644
--- a/runtime/go/build.go
+++ b/runtime/go/build.go
@@ -153,7 +153,6 @@ func specMethods(parcel *cfc.Parcel) {
 	stringBinding := cfc.NewGoClass(parcel, "Clownfish::String")
 	stringBinding.SpecMethod("Code_Point_At", "CodePointAt(uintptr) rune")
 	stringBinding.SpecMethod("Code_Point_From", "CodePointFrom(uintptr) rune")
-	stringBinding.SpecMethod("Swap_Chars", "SwapChars(rune, rune) string")
 	stringBinding.Register()
 
 	stringIterBinding := cfc.NewGoClass(parcel, "Clownfish::StringIterator")

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0bfc3498/runtime/go/clownfish/clownfish.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/clownfish.go b/runtime/go/clownfish/clownfish.go
index a881cda..1986109 100644
--- a/runtime/go/clownfish/clownfish.go
+++ b/runtime/go/clownfish/clownfish.go
@@ -655,13 +655,6 @@ func (s *StringIMP) CodePointFrom(tick uintptr) rune {
 	return rune(retvalCF)
 }
 
-func (s *StringIMP) SwapChars(match, replacement rune) string {
-	self := ((*C.cfish_String)(Unwrap(s, "s")))
-	retvalCF := C.CFISH_Str_Swap_Chars(self, C.int32_t(match), C.int32_t(replacement))
-	defer C.cfish_dec_refcount(unsafe.Pointer(retvalCF))
-	return CFStringToGo(unsafe.Pointer(retvalCF))
-}
-
 func NewBoolean(val bool) Boolean {
 	if val {
 		return WRAPBoolean(unsafe.Pointer(C.cfish_inc_refcount(unsafe.Pointer(C.CFISH_TRUE))))

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0bfc3498/runtime/go/clownfish/string_test.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/string_test.go b/runtime/go/clownfish/string_test.go
index 1347b19..6f8c641 100644
--- a/runtime/go/clownfish/string_test.go
+++ b/runtime/go/clownfish/string_test.go
@@ -26,14 +26,6 @@ func TestStringCat(t *testing.T) {
 	}
 }
 
-func TestStringSwapChars(t *testing.T) {
-	s := NewString("foo")
-	got := s.SwapChars('o', 'u')
-	if got != "fuu" {
-		t.Error("Expected 'fuu', got", got)
-	}
-}
-
 func TestStringStartsWithEndsWith(t *testing.T) {
 	s := NewString("foobar")
 	if !s.StartsWith("foo") {


Mime
View raw message