Navigation Menu

Skip to content

Commit

Permalink
Invert subrec size and GRN_RSET_SCORES_SIZE
Browse files Browse the repository at this point in the history
Because score is stored before subrec:

    |-score1-|-subrec1-|-score2-|-subrec2-|...|
  • Loading branch information
kou committed Jun 25, 2014
1 parent 77ec961 commit bc5f681
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/db.c
Expand Up @@ -1988,7 +1988,7 @@ subrecs_push(byte *subrecs, int size, int n_subrecs, int score, void *body, int
GRN_RSET_SUBRECS_COPY(subrecs,size,n,c2);
n = n2;
}
v = subrecs + n * (size + GRN_RSET_SCORE_SIZE);
v = subrecs + n * (GRN_RSET_SCORE_SIZE + size);
*((int *)v) = score;
memcpy(v + GRN_RSET_SCORE_SIZE, body, size);
}
Expand Down Expand Up @@ -2022,7 +2022,7 @@ subrecs_replace_min(byte *subrecs, int size, int n_subrecs, int score, void *bod
}
}
}
v = subrecs + n * (size + GRN_RSET_SCORE_SIZE);
v = subrecs + n * (GRN_RSET_SCORE_SIZE + size);
memcpy(v, &score, GRN_RSET_SCORE_SIZE);
memcpy(v + GRN_RSET_SCORE_SIZE, body, size);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/db.h
Expand Up @@ -58,9 +58,9 @@ typedef struct {

#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)))
((int *)((byte *)subrecs + n * (GRN_RSET_SCORE_SIZE + size)))
#define GRN_RSET_SUBRECS_COPY(subrecs,size,n,src) \
(memcpy(GRN_RSET_SUBRECS_NTH(subrecs, size, n), src, size + GRN_RSET_SCORE_SIZE))
(memcpy(GRN_RSET_SUBRECS_NTH(subrecs, size, n), src, GRN_RSET_SCORE_SIZE + size))

#define GRN_JSON_LOAD_OPEN_BRACKET 0x40000000
#define GRN_JSON_LOAD_OPEN_BRACE 0x40000001
Expand Down

0 comments on commit bc5f681

Please sign in to comment.