[Groonga-commit] groonga/groonga at 46ad383 [master] Change the behavior of GRN_RSET_SUBRECS_CMP().

Back to archive index

Daijiro MORI null+****@clear*****
Fri Jun 21 14:01:10 JST 2013


Daijiro MORI	2013-06-21 14:01:10 +0900 (Fri, 21 Jun 2013)

  New Revision: 46ad38337ada7520af3a8051abb3da4bd99bbf0f
  https://github.com/groonga/groonga/commit/46ad38337ada7520af3a8051abb3da4bd99bbf0f

  Message:
    Change the behavior of GRN_RSET_SUBRECS_CMP().

  Modified files:
    lib/db.c
    lib/db.h
    lib/hash.c

  Modified: lib/db.c (+6 -6)
===================================================================
--- lib/db.c    2013-06-21 13:10:19 +0900 (5894a2e)
+++ lib/db.c    2013-06-21 14:01:10 +0900 (0113495)
@@ -1867,7 +1867,7 @@ subrecs_push(byte *subrecs, int size, int n_subrecs, int score, void *body, int
   while (n) {
     n2 = (n - 1) >> 1;
     c2 = GRN_RSET_SUBRECS_NTH(subrecs,size,n2);
-    if (GRN_RSET_SUBRECS_CMP(score, *c2, dir)) { break; }
+    if (GRN_RSET_SUBRECS_CMP(score, *c2, dir) > 0) { break; }
     GRN_RSET_SUBRECS_COPY(subrecs,size,n,c2);
     n = n2;
   }
@@ -1886,10 +1886,10 @@ subrecs_replace_min(byte *subrecs, int size, int n_subrecs, int score, void *bod
     n2 = n1 + 1;
     c1 = n1 < n_subrecs ? GRN_RSET_SUBRECS_NTH(subrecs,size,n1) : NULL;
     c2 = n2 < n_subrecs ? GRN_RSET_SUBRECS_NTH(subrecs,size,n2) : NULL;
-    if (c1 && GRN_RSET_SUBRECS_CMP(score, *c1, dir)) {
+    if (c1 && GRN_RSET_SUBRECS_CMP(score, *c1, dir) > 0) {
       if (c2 &&
-          GRN_RSET_SUBRECS_CMP(score, *c2, dir) &&
-          GRN_RSET_SUBRECS_CMP(*c1, *c2, dir)) {
+          GRN_RSET_SUBRECS_CMP(score, *c2, dir) > 0 &&
+          GRN_RSET_SUBRECS_CMP(*c1, *c2, dir) > 0) {
         GRN_RSET_SUBRECS_COPY(subrecs,size,n,c2);
         n = n2;
       } else {
@@ -1897,7 +1897,7 @@ subrecs_replace_min(byte *subrecs, int size, int n_subrecs, int score, void *bod
         n = n1;
       }
     } else {
-      if (c2 && GRN_RSET_SUBRECS_CMP(score, *c2, dir)) {
+      if (c2 && GRN_RSET_SUBRECS_CMP(score, *c2, dir) > 0) {
         GRN_RSET_SUBRECS_COPY(subrecs,size,n,c2);
         n = n2;
       } else {
@@ -1924,7 +1924,7 @@ grn_table_add_subrec_inline(grn_obj *table, grn_rset_recinfo *ri, int score,
       if (pi) {
         byte *body = (byte *)pi + DB_OBJ(table)->subrec_offset;
         if (limit < n_subrecs) {
-          if (GRN_RSET_SUBRECS_CMP(score, *ri->subrecs, dir)) {
+          if (GRN_RSET_SUBRECS_CMP(score, *ri->subrecs, dir) > 0) {
             subrecs_replace_min((byte *)ri->subrecs, subrec_size, limit, score, body, dir);
           }
         } else {

  Modified: lib/db.h (+1 -1)
===================================================================
--- lib/db.h    2013-06-21 13:10:19 +0900 (e3a49a4)
+++ lib/db.h    2013-06-21 14:01:10 +0900 (6d129e5)
@@ -56,7 +56,7 @@ typedef struct {
 
 #define GRN_RSET_N_SUBRECS(ri) ((ri)->n_subrecs & ~GRN_RSET_UTIL_BIT)
 
-#define GRN_RSET_SUBRECS_CMP(a,b,dir) (((a) - (b))*(dir) > 0)
+#define GRN_RSET_SUBRECS_CMP(a,b,dir) (((a) - (b))*(dir))
 #define GRN_RSET_SUBRECS_NTH(subrecs,size,n) \
   ((int *)((byte *)subrecs + n * (size + GRN_RSET_SCORE_SIZE)))
 #define GRN_RSET_SUBRECS_COPY(subrecs,size,n,src) \

  Modified: lib/hash.c (+6 -6)
===================================================================
--- lib/hash.c    2013-06-21 13:10:19 +0900 (406e787)
+++ lib/hash.c    2013-06-21 14:01:10 +0900 (d3a28c5)
@@ -3146,7 +3146,7 @@ subrecs_push(byte *subrecs, int size, int n_subrecs, int score, void *body, int
   while (n) {
     n2 = (n - 1) >> 1;
     c2 = GRN_RSET_SUBRECS_NTH(subrecs,size,n2);
-    if (GRN_RSET_SUBRECS_CMP(score, *c2, dir)) { break; }
+    if (GRN_RSET_SUBRECS_CMP(score, *c2, dir) > 0) { break; }
     GRN_RSET_SUBRECS_COPY(subrecs,size,n,c2);
     n = n2;
   }
@@ -3165,10 +3165,10 @@ subrecs_replace_min(byte *subrecs, int size, int n_subrecs, int score, void *bod
     n2 = n1 + 1;
     c1 = n1 < n_subrecs ? GRN_RSET_SUBRECS_NTH(subrecs,size,n1) : NULL;
     c2 = n2 < n_subrecs ? GRN_RSET_SUBRECS_NTH(subrecs,size,n2) : NULL;
-    if (c1 && GRN_RSET_SUBRECS_CMP(score, *c1, dir)) {
+    if (c1 && GRN_RSET_SUBRECS_CMP(score, *c1, dir) > 0) {
       if (c2 &&
-          GRN_RSET_SUBRECS_CMP(score, *c2, dir) &&
-          GRN_RSET_SUBRECS_CMP(*c1, *c2, dir)) {
+          GRN_RSET_SUBRECS_CMP(score, *c2, dir) > 0 &&
+          GRN_RSET_SUBRECS_CMP(*c1, *c2, dir) > 0) {
         GRN_RSET_SUBRECS_COPY(subrecs,size,n,c2);
         n = n2;
       } else {
@@ -3176,7 +3176,7 @@ subrecs_replace_min(byte *subrecs, int size, int n_subrecs, int score, void *bod
         n = n1;
       }
     } else {
-      if (c2 && GRN_RSET_SUBRECS_CMP(score, *c2, dir)) {
+      if (c2 && GRN_RSET_SUBRECS_CMP(score, *c2, dir) > 0) {
         GRN_RSET_SUBRECS_COPY(subrecs,size,n,c2);
         n = n2;
       } else {
@@ -3199,7 +3199,7 @@ grn_rhash_add_subrec(grn_hash *s, grn_rset_recinfo *ri, int score, void *body, i
     int ssize = s->subrec_size;
     int n_subrecs = GRN_RSET_N_SUBRECS(ri);
     if (limit < n_subrecs) {
-      if (GRN_RSET_SUBRECS_CMP(score, *ri->subrecs, dir)) {
+      if (GRN_RSET_SUBRECS_CMP(score, *ri->subrecs, dir) > 0) {
         subrecs_replace_min(ri->subrecs, ssize, limit, score, body, dir);
       }
     } else {
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index