lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [20/20] git commit: refs/heads/cfish-string-prep1 - Convert Util::Json to StringIterator
Date Sat, 07 Sep 2013 16:53:41 GMT
Convert Util::Json to StringIterator


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

Branch: refs/heads/cfish-string-prep1
Commit: ab80bcf5383f4dc6f08e606f1ee69233abed551a
Parents: c053487
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat Sep 7 17:59:45 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat Sep 7 18:14:05 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Util/Json.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/ab80bcf5/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index 33295a1..61018d6 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -175,14 +175,14 @@ Json_set_tolerant(bool tolerance) {
 static const int32_t MAX_DEPTH = 200;
 
 static void
-S_append_json_string(Obj *dump, CharBuf *buf) {
+S_append_json_string(String *dump, CharBuf *buf) {
     // Append opening quote.
     CB_Cat_Trusted_UTF8(buf, "\"", 1);
 
     // Process string data.
-    StackString *iterator = SSTR_WRAP((String*)dump);
-    while (SStr_Get_Size(iterator)) {
-        uint32_t code_point = SStr_Nibble(iterator);
+    StringIterator *iter = Str_Top(dump);
+    uint32_t code_point;
+    while (STRITER_DONE != (code_point = StrIter_Next(iter))) {
         if (code_point > 127) {
             // There is no need to escape any high characters, including those
             // above the BMP, as we assume that the destination channel can
@@ -247,6 +247,8 @@ S_append_json_string(Obj *dump, CharBuf *buf) {
 
     // Append closing quote.
     CB_Cat_Trusted_UTF8(buf, "\"", 1);
+
+    DECREF(iter);
 }
 
 static void
@@ -275,7 +277,7 @@ S_to_json(Obj *dump, CharBuf *buf, int32_t depth) {
         CB_Cat_Trusted_UTF8(buf, "false", 5);
     }
     else if (Obj_Is_A(dump, STRING)) {
-        S_append_json_string(dump, buf);
+        S_append_json_string((String*)dump, buf);
     }
     else if (Obj_Is_A(dump, INTNUM)) {
         CB_catf(buf, "%i64", Obj_To_I64(dump));
@@ -349,7 +351,7 @@ S_to_json(Obj *dump, CharBuf *buf, int32_t depth) {
             Obj *key = VA_Fetch(keys, i);
             CB_Cat_Trusted_UTF8(buf, "\n", 1);
             S_cat_whitespace(buf, depth + 1);
-            S_append_json_string(key, buf);
+            S_append_json_string((String*)key, buf);
             CB_Cat_Trusted_UTF8(buf, ": ", 2);
             if (!S_to_json(Hash_Fetch(hash, key), buf, depth + 1)) {
                 DECREF(keys);
@@ -684,7 +686,7 @@ S_set_error(CharBuf *buf, char *json, char *limit, int line,
         len = end - json;
     }
     StackString *snippet = SSTR_WRAP_STR(json, len);
-    S_append_json_string((Obj*)snippet, buf);
+    S_append_json_string((String*)snippet, buf);
 
     String *mess = CB_Yield_String(buf);
     DECREF(buf);


Mime
View raw message