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/01 22:17:08 UTC

[lucy-commits] [20/24] git commit: refs/heads/cfish-string-prep1 - Convert Index::DocVector to CharBuf

Convert Index::DocVector to CharBuf


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

Branch: refs/heads/cfish-string-prep1
Commit: 859a53d3bbb8d0d2de76e7ad417f62dcc6115022
Parents: 34e663a
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Sep 1 21:05:02 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sun Sep 1 22:05:03 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Index/DocVector.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/859a53d3/core/Lucy/Index/DocVector.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocVector.c b/core/Lucy/Index/DocVector.c
index dcece25..5821f90 100644
--- a/core/Lucy/Index/DocVector.c
+++ b/core/Lucy/Index/DocVector.c
@@ -18,6 +18,8 @@
 #include "Lucy/Util/ToolSet.h"
 
 #include "Lucy/Index/DocVector.h"
+
+#include "Clownfish/CharBuf.h"
 #include "Lucy/Index/TermVector.h"
 #include "Lucy/Store/InStream.h"
 #include "Lucy/Store/OutStream.h"
@@ -121,7 +123,7 @@ S_extract_tv_cache(ByteBuf *field_buf) {
     Hash    *tv_cache  = Hash_new(0);
     char    *tv_string = BB_Get_Buf(field_buf);
     int32_t  num_terms = NumUtil_decode_c32(&tv_string);
-    String  *text      = Str_new(0);
+    CharBuf *text_buf  = CB_new(0);
 
     // Read the number of highlightable terms in the field.
     for (int32_t i = 0; i < num_terms; i++) {
@@ -129,8 +131,8 @@ S_extract_tv_cache(ByteBuf *field_buf) {
         size_t   len     = NumUtil_decode_c32(&tv_string);
 
         // Decompress the term text.
-        Str_Set_Size(text, overlap);
-        Str_Cat_Trusted_Str(text, tv_string, len);
+        CB_Set_Size(text_buf, overlap);
+        CB_Cat_Trusted_UTF8(text_buf, tv_string, len);
         tv_string += len;
 
         // Get positions & offsets string.
@@ -145,10 +147,12 @@ S_extract_tv_cache(ByteBuf *field_buf) {
         len = tv_string - bookmark_ptr;
 
         // Store the $text => $posdata pair in the output hash.
+        String *text = CB_To_String(text_buf);
         Hash_Store(tv_cache, (Obj*)text,
                    (Obj*)BB_new_bytes(bookmark_ptr, len));
+        DECREF(text);
     }
-    DECREF(text);
+    DECREF(text_buf);
 
     return tv_cache;
 }