Skip to content

Commit

Permalink
Use bit operation for flags
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Feb 5, 2016
1 parent f9fc020 commit c2f0659
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/pat.c
Expand Up @@ -1320,7 +1320,7 @@ calc_edit_distance_by_offset(grn_ctx *ctx,
b = DIST(x, y - 1) + 1;
c = DIST(x - 1, y - 1) + 1;
DIST(x, y) = ((a < b) ? ((a < c) ? a : c) : ((b < c) ? b : c));
if (flags == GRN_TABLE_FUZZY_SEARCH_WITH_TRANSPOSITION
if (flags & GRN_TABLE_FUZZY_SEARCH_WITH_TRANSPOSITION
&& x > 1 && y > 1
&& cx == cy
&& memcmp(px, py - cy, cx) == 0
Expand Down
6 changes: 3 additions & 3 deletions lib/proc.c
Expand Up @@ -4341,7 +4341,7 @@ calc_edit_distance(grn_ctx *ctx, char *sx, char *ex, char *sy, char *ey, int fla
uint32_t b = DIST(x, y - 1) + 1;
uint32_t c = DIST(x - 1, y - 1) + 1;
DIST(x, y) = ((a < b) ? ((a < c) ? a : c) : ((b < c) ? b : c));
if (flags == GRN_TABLE_FUZZY_SEARCH_WITH_TRANSPOSITION
if (flags & GRN_TABLE_FUZZY_SEARCH_WITH_TRANSPOSITION
&& x > 1 && y > 1 && cx == cy
&& memcmp(px, py - cy, cx) == 0
&& memcmp(px - cx, py, cx) == 0) {
Expand All @@ -4367,7 +4367,7 @@ func_edit_distance(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_
grn_obj *obj;
if (nargs >= N_REQUIRED_ARGS && nargs <= MAX_ARGS) {
if (nargs == MAX_ARGS && GRN_BOOL_VALUE(args[2])) {
flags = GRN_TABLE_FUZZY_SEARCH_WITH_TRANSPOSITION;
flags |= GRN_TABLE_FUZZY_SEARCH_WITH_TRANSPOSITION;
}
d = calc_edit_distance(ctx, GRN_TEXT_VALUE(args[0]), GRN_BULK_CURR(args[0]),
GRN_TEXT_VALUE(args[1]), GRN_BULK_CURR(args[1]), flags);
Expand Down Expand Up @@ -7044,7 +7044,7 @@ selector_fuzzy_search(grn_ctx *ctx, grn_obj *table, grn_obj *index,
}
if (nargs == 7) {
if (GRN_BOOL_VALUE(args[6])) {
flags = GRN_TABLE_FUZZY_SEARCH_WITH_TRANSPOSITION;
flags |= GRN_TABLE_FUZZY_SEARCH_WITH_TRANSPOSITION;
}
}

Expand Down

0 comments on commit c2f0659

Please sign in to comment.