lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [18/20] git commit: refs/heads/cfish-string-prep1 - Remove String methods Nip, Nibble, Chop, and Truncate
Date Sat, 07 Sep 2013 16:53:39 GMT
Remove String methods Nip, Nibble, Chop, and Truncate


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

Branch: refs/heads/cfish-string-prep1
Commit: ee3c8ed8f7703e449f4527f52b08f8342f785777
Parents: fed2b10
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat Sep 7 18:10:48 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat Sep 7 18:14:05 2013 +0200

----------------------------------------------------------------------
 clownfish/runtime/core/Clownfish/String.c       | 58 --------------------
 clownfish/runtime/core/Clownfish/String.cfh     | 27 ---------
 .../runtime/core/Clownfish/Test/TestString.c    | 38 +------------
 3 files changed, 1 insertion(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/ee3c8ed8/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index c87864a..d1d36d1 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -484,15 +484,6 @@ Str_Length_IMP(String *self) {
     return SStrIter_Advance(iter, SIZE_MAX);
 }
 
-size_t
-Str_Truncate_IMP(String *self, size_t count) {
-    uint32_t num_code_points;
-    StackString *iterator = SSTR_WRAP(self);
-    num_code_points = SStr_Nip(iterator, count);
-    self->size -= iterator->size;
-    return num_code_points;
-}
-
 uint32_t
 Str_Code_Point_At_IMP(String *self, size_t tick) {
     StackStringIterator *iter = STR_STACKTOP(self);
@@ -666,55 +657,6 @@ ViewCB_Trim_Top_IMP(ViewCharBuf *self) {
     return count;
 }
 
-size_t
-ViewCB_Nip_IMP(ViewCharBuf *self, size_t count) {
-    size_t  num_nipped;
-    char   *ptr = self->ptr;
-    char   *end = ptr + self->size;
-    for (num_nipped = 0;
-         ptr < end && count--;
-         ptr += StrHelp_UTF8_COUNT[*(uint8_t*)ptr]
-        ) {
-        num_nipped++;
-    }
-    if (ptr > end) {
-        DIE_INVALID_UTF8(self->ptr, self->size);
-    }
-    self->size = end - ptr;
-    self->ptr  = ptr;
-    return num_nipped;
-}
-
-int32_t
-ViewCB_Nibble_IMP(ViewCharBuf *self) {
-    if (self->size == 0) {
-        return 0;
-    }
-    else {
-        int32_t retval = (int32_t)StrHelp_decode_utf8_char(self->ptr);
-        size_t consumed = StrHelp_UTF8_COUNT[*(uint8_t*)self->ptr];
-        if (consumed > self->size) {
-            DIE_INVALID_UTF8(self->ptr, self->size);
-        }
-        self->ptr  += consumed;
-        self->size -= consumed;
-        return retval;
-    }
-}
-
-size_t
-ViewCB_Chop_IMP(ViewCharBuf *self, size_t count) {
-    size_t      num_chopped = 0;
-    char       *top         = self->ptr;
-    const char *ptr         = top + self->size;
-    for (num_chopped = 0; num_chopped < count; num_chopped++) {
-        const char *end = ptr;
-        if (NULL == (ptr = StrHelp_back_utf8_char(ptr, top))) { break; }
-        self->size -= (end - ptr);
-    }
-    return num_chopped;
-}
-
 char*
 ViewCB_Grow_IMP(ViewCharBuf *self, size_t size) {
     UNUSED_VAR(size);

http://git-wip-us.apache.org/repos/asf/lucy/blob/ee3c8ed8/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index d8e32dd..bf56e22 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -239,15 +239,6 @@ class Clownfish::String cnick Str
     uint32_t
     Trim_Tail(String *self);
 
-    /** Truncate the String so that it contains no more than
-     * <code>count</code>characters.
-     *
-     * @param count Maximum new length, in Unicode code points.
-     * @return The number of code points left in the string after truncation.
-     */
-    size_t
-    Truncate(String *self, size_t count);
-
     /** Return the Unicode code point at the specified number of code points
      * in.  Return 0 if the string length is exceeded.  (XXX It would be
      * better to throw an exception, but that's not practical with UTF-8 and
@@ -316,24 +307,6 @@ class Clownfish::ViewCharBuf cnick ViewCB
     uint32_t
     Trim_Top(ViewCharBuf *self);
 
-    /** Remove characters (measured in code points) from the top of the
-     * ViewCharBuf.  Returns the number nipped.
-     */
-    size_t
-    Nip(ViewCharBuf *self, size_t count);
-
-    /** Remove one character from the top of the ViewCharBuf.  Returns the
-     * code point, or 0 if the string was empty.
-     */
-    int32_t
-    Nibble(ViewCharBuf *self);
-
-    /** Remove characters (measured in code points) from the end of the
-     * ViewCharBuf.  Returns the number chopped.
-     */
-    size_t
-    Chop(ViewCharBuf *self, size_t count);
-
     /** Throws an error. */
     char*
     Grow(ViewCharBuf *self, size_t size);

http://git-wip-us.apache.org/repos/asf/lucy/blob/ee3c8ed8/clownfish/runtime/core/Clownfish/Test/TestString.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestString.c b/clownfish/runtime/core/Clownfish/Test/TestString.c
index 72f2ecf..75616fd 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestString.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestString.c
@@ -174,40 +174,6 @@ test_SubString(TestBatchRunner *runner) {
 }
 
 static void
-test_Nip_and_Chop(TestBatchRunner *runner) {
-    String *wanted;
-    String *string;
-    StackString *got;
-
-    wanted = Str_newf("%sb%sc", smiley, smiley);
-    string = Str_newf("a%s%sb%sc", smiley, smiley, smiley);
-    got    = SSTR_WRAP(string);
-    SStr_Nip(got, 2);
-    TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Nip");
-    DECREF(wanted);
-    DECREF(string);
-
-    wanted = Str_newf("a%s%s", smiley, smiley);
-    string = Str_newf("a%s%sb%sc", smiley, smiley, smiley);
-    got    = SSTR_WRAP(string);
-    SStr_Chop(got, 3);
-    TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Chop");
-    DECREF(wanted);
-    DECREF(string);
-}
-
-
-static void
-test_Truncate(TestBatchRunner *runner) {
-    String *wanted = Str_newf("a%s", smiley, smiley);
-    String *got    = Str_newf("a%s%sb%sc", smiley, smiley, smiley);
-    Str_Truncate(got, 2);
-    TEST_TRUE(runner, Str_Equals(wanted, (Obj*)got), "Truncate");
-    DECREF(wanted);
-    DECREF(got);
-}
-
-static void
 test_Trim(TestBatchRunner *runner) {
     String *got;
 
@@ -490,14 +456,12 @@ test_iterator_substring(TestBatchRunner *runner) {
 
 void
 TestStr_Run_IMP(TestString *self, TestBatchRunner *runner) {
-    TestBatchRunner_Plan(runner, (TestBatch*)self, 105);
+    TestBatchRunner_Plan(runner, (TestBatch*)self, 102);
     test_Cat(runner);
     test_Mimic_and_Clone(runner);
     test_Code_Point_At_and_From(runner);
     test_Find(runner);
     test_SubString(runner);
-    test_Nip_and_Chop(runner);
-    test_Truncate(runner);
     test_Trim(runner);
     test_To_F64(runner);
     test_To_I64(runner);


Mime
View raw message