You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2013/07/17 16:12:46 UTC

[lucy-commits] [26/34] git commit: refs/heads/master - Use Token accessors within HighlightWriter.

Use Token accessors within HighlightWriter.

Use accessors rather than direct struct access when reading Tokens
within HighlightWriter.


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

Branch: refs/heads/master
Commit: 6346d10be88d44d038009bf64544c83587c60911
Parents: e894b7c
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Thu Jul 11 16:04:35 2013 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Tue Jul 16 16:08:43 2013 -0700

----------------------------------------------------------------------
 core/Lucy/Index/HighlightWriter.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/6346d10b/core/Lucy/Index/HighlightWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/HighlightWriter.c b/core/Lucy/Index/HighlightWriter.c
index d1ce83a..60154df 100644
--- a/core/Lucy/Index/HighlightWriter.c
+++ b/core/Lucy/Index/HighlightWriter.c
@@ -16,7 +16,6 @@
 
 #define C_LUCY_HIGHLIGHTWRITER
 #define C_LUCY_DEFAULTHIGHLIGHTWRITER
-#define C_LUCY_TOKEN
 #include "Lucy/Util/ToolSet.h"
 
 #include <stdio.h>
@@ -155,16 +154,18 @@ HLWriter_tv_buf(HighlightWriter *self, Inversion *inversion) {
     Inversion_Reset(inversion);
     while ((tokens = Inversion_Next_Cluster(inversion, &freq)) != NULL) {
         Token *token = *tokens;
-        TokenIVARS *token_ivars = Token_IVARS(token);
-        int32_t overlap = StrHelp_overlap(last_text, token_ivars->text,
-                                          last_len, token_ivars->len);
+        char *const   token_text = Token_Get_Text(token);
+        const int32_t token_len  = Token_Get_Len(token);
+
+        int32_t overlap = StrHelp_overlap(last_text, token_text,
+                                          last_len, token_len);
         char *ptr;
         char *orig;
         size_t old_size = BB_Get_Size(tv_buf);
         size_t new_size = old_size
                           + C32_MAX_BYTES      // overlap
                           + C32_MAX_BYTES      // length of string diff
-                          + (token_ivars->len - overlap) // diff char data
+                          + (token_len - overlap)        // diff char data
                           + C32_MAX_BYTES                // num prox
                           + (C32_MAX_BYTES * freq * 3);  // pos data
 
@@ -178,25 +179,22 @@ HLWriter_tv_buf(HighlightWriter *self, Inversion *inversion) {
 
         // Append the string diff to the tv_buf.
         NumUtil_encode_c32(overlap, &ptr);
-        NumUtil_encode_c32((token_ivars->len - overlap), &ptr);
-        memcpy(ptr, (token_ivars->text + overlap),
-               (token_ivars->len - overlap));
-        ptr += token_ivars->len - overlap;
+        NumUtil_encode_c32((token_len - overlap), &ptr);
+        memcpy(ptr, (token_text + overlap), (token_len - overlap));
+        ptr += token_len - overlap;
 
         // Save text and text_len for comparison next loop.
-        last_text = token_ivars->text;
-        last_len  = token_ivars->len;
+        last_text = token_text;
+        last_len  = token_len;
 
         // Append the number of positions for this term.
         NumUtil_encode_c32(freq, &ptr);
 
         do {
-            token_ivars = Token_IVARS(token);
             // Add position, start_offset, and end_offset to tv_buf.
-            NumUtil_encode_c32(token_ivars->pos, &ptr);
-            NumUtil_encode_c32(token_ivars->start_offset, &ptr);
-            NumUtil_encode_c32(token_ivars->end_offset, &ptr);
-
+            NumUtil_encode_c32(Token_Get_Pos(token), &ptr);
+            NumUtil_encode_c32(Token_Get_Start_Offset(token), &ptr);
+            NumUtil_encode_c32(Token_Get_End_Offset(token), &ptr);
         } while (--freq && (token = *++tokens));
 
         // Set new byte length.