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 2014/08/13 17:52:02 UTC

[3/5] git commit: refs/heads/master - Pass const pointers to NumUtil decode functions

Pass const pointers to NumUtil decode functions


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

Branch: refs/heads/master
Commit: 4e1caaf82a539f07d4ae98828e197f29b405f601
Parents: d4fc5d4
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Aug 10 02:19:53 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Aug 12 21:36:11 2014 +0200

----------------------------------------------------------------------
 core/Lucy/Index/DocVector.c             | 16 ++++++++--------
 core/Lucy/Index/Posting/ScorePosting.c  |  2 +-
 core/Lucy/Store/InStream.c              |  4 ++--
 core/Lucy/Store/InStream.cfh            |  2 +-
 core/Lucy/Test/Store/TestIOPrimitives.c |  2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/4e1caaf8/core/Lucy/Index/DocVector.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocVector.c b/core/Lucy/Index/DocVector.c
index daeba31..0cb0aae 100644
--- a/core/Lucy/Index/DocVector.c
+++ b/core/Lucy/Index/DocVector.c
@@ -120,10 +120,10 @@ DocVec_Term_Vector_IMP(DocVector *self, String *field,
 
 static Hash*
 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);
-    CharBuf *text_buf  = CB_new(0);
+    Hash       *tv_cache  = Hash_new(0);
+    const char *tv_string = BB_Get_Buf(field_buf);
+    int32_t     num_terms = NumUtil_decode_c32(&tv_string);
+    CharBuf    *text_buf  = CB_new(0);
 
     // Read the number of highlightable terms in the field.
     for (int32_t i = 0; i < num_terms; i++) {
@@ -136,8 +136,8 @@ S_extract_tv_cache(ByteBuf *field_buf) {
         tv_string += len;
 
         // Get positions & offsets string.
-        char *bookmark_ptr      = tv_string;
-        int32_t num_positions   = NumUtil_decode_c32(&tv_string);
+        const char *bookmark_ptr  = tv_string;
+        int32_t     num_positions = NumUtil_decode_c32(&tv_string);
         while (num_positions--) {
             // Leave nums compressed to save a little mem.
             NumUtil_skip_cint(&tv_string);
@@ -161,8 +161,8 @@ static TermVector*
 S_extract_tv_from_tv_buf(String *field, String *term_text,
                          ByteBuf *tv_buf) {
     TermVector *retval      = NULL;
-    char       *posdata     = BB_Get_Buf(tv_buf);
-    char       *posdata_end = posdata + BB_Get_Size(tv_buf);
+    const char *posdata     = BB_Get_Buf(tv_buf);
+    const char *posdata_end = posdata + BB_Get_Size(tv_buf);
     int32_t    *positions   = NULL;
     int32_t    *starts      = NULL;
     int32_t    *ends        = NULL;

http://git-wip-us.apache.org/repos/asf/lucy/blob/4e1caaf8/core/Lucy/Index/Posting/ScorePosting.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Posting/ScorePosting.c b/core/Lucy/Index/Posting/ScorePosting.c
index f812c5b..18b4692 100644
--- a/core/Lucy/Index/Posting/ScorePosting.c
+++ b/core/Lucy/Index/Posting/ScorePosting.c
@@ -134,7 +134,7 @@ ScorePost_Read_Record_IMP(ScorePosting *self, InStream *instream) {
     ScorePostingIVARS *const ivars = ScorePost_IVARS(self);
     uint32_t  position = 0;
     const size_t max_start_bytes = (C32_MAX_BYTES * 2) + 1;
-    char *buf = InStream_Buf(instream, max_start_bytes);
+    const char *buf = InStream_Buf(instream, max_start_bytes);
     const uint32_t doc_code = NumUtil_decode_c32(&buf);
     const uint32_t doc_delta = doc_code >> 1;
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/4e1caaf8/core/Lucy/Store/InStream.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/InStream.c b/core/Lucy/Store/InStream.c
index 366caca..8a47ff7 100644
--- a/core/Lucy/Store/InStream.c
+++ b/core/Lucy/Store/InStream.c
@@ -318,7 +318,7 @@ InStream_Buf_IMP(InStream *self, size_t request) {
 }
 
 void
-InStream_Advance_Buf_IMP(InStream *self, char *buf) {
+InStream_Advance_Buf_IMP(InStream *self, const char *buf) {
     InStreamIVARS *const ivars = InStream_IVARS(self);
     if (buf > ivars->limit) {
         int64_t overrun = CHY_PTR_TO_I64(buf) - CHY_PTR_TO_I64(ivars->limit);
@@ -330,7 +330,7 @@ InStream_Advance_Buf_IMP(InStream *self, char *buf) {
         THROW(ERR, "Can't Advance_Buf backwards: (underrun: %i64))", underrun);
     }
     else {
-        ivars->buf = buf;
+        ivars->buf += buf - ivars->buf;
     }
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/4e1caaf8/core/Lucy/Store/InStream.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/InStream.cfh b/core/Lucy/Store/InStream.cfh
index 88a099f..6a7a89c 100644
--- a/core/Lucy/Store/InStream.cfh
+++ b/core/Lucy/Store/InStream.cfh
@@ -123,7 +123,7 @@ class Lucy::Store::InStream inherits Clownfish::Obj {
      * Advance_Buf() to update the InStream object.
      */
     final void
-    Advance_Buf(InStream *self, char *buf);
+    Advance_Buf(InStream *self, const char *buf);
 
     /** Read <code>len</code> bytes from the InStream into <code>buf</code>.
      */

http://git-wip-us.apache.org/repos/asf/lucy/blob/4e1caaf8/core/Lucy/Test/Store/TestIOPrimitives.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestIOPrimitives.c b/core/Lucy/Test/Store/TestIOPrimitives.c
index 66caf76..30008d6 100644
--- a/core/Lucy/Test/Store/TestIOPrimitives.c
+++ b/core/Lucy/Test/Store/TestIOPrimitives.c
@@ -319,7 +319,7 @@ test_c64(TestBatchRunner *runner) {
     raw_instream = InStream_open((Obj*)raw_file);
     for (i = 0; i < 1000; i++) {
         char  buffer[10];
-        char *buf = buffer;
+        const char *buf = buffer;
         size_t size = InStream_Read_Raw_C64(raw_instream, buffer);
         uint64_t got = NumUtil_decode_c64(&buf);
         UNUSED_VAR(size);