You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/09/07 18:53:25 UTC

[lucy-commits] [04/20] git commit: refs/heads/cfish-string-prep1 - Convert Index::Segment to StringIterator

Convert Index::Segment to StringIterator


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

Branch: refs/heads/cfish-string-prep1
Commit: c56353bdabe13a9285d6ee66d2215c4059f84ee4
Parents: f374f95
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Sep 7 14:44:44 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Sep 7 18:14:04 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Index/Segment.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/c56353bd/core/Lucy/Index/Segment.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Segment.c b/core/Lucy/Index/Segment.c
index bd283d0..d375e98 100644
--- a/core/Lucy/Index/Segment.c
+++ b/core/Lucy/Index/Segment.c
@@ -66,13 +66,17 @@ Seg_num_to_name(int64_t number) {
 bool
 Seg_valid_seg_name(const String *name) {
     if (Str_Starts_With_Str(name, "seg_", 4)) {
-        StackString *scratch = SSTR_WRAP(name);
-        SStr_Nip(scratch, 4);
+        StringIterator *iter = Str_Top(name);
+        StrIter_Advance(iter, 4);
         uint32_t code_point;
-        while (0 != (code_point = SStr_Nibble(scratch))) {
-            if (!isalnum(code_point)) { return false; }
+        while (STRITER_DONE != (code_point = StrIter_Next(iter))) {
+            if (!isalnum(code_point)) {
+                DECREF(iter);
+                return false;
+            }
         }
-        if (SStr_Get_Size(scratch) == 0) { return true; } // Success!
+        DECREF(iter);
+        return true; // Success!
     }
     return false;
 }