Skip to content

Commit

Permalink
Don't show "DDL:set_token_filters" log when it's not needed
Browse files Browse the repository at this point in the history
Not needed case:

  * Both the current token filters and new token filters are empty.
  • Loading branch information
kou committed Nov 8, 2014
1 parent d8a065a commit ae29322
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -6842,7 +6842,7 @@ grn_obj_set_info_token_filters(grn_ctx *ctx,
grn_obj *token_filters)
{
grn_obj *current_token_filters;
unsigned int i, n_token_filters;
unsigned int i, n_current_token_filters, n_token_filters;
grn_obj token_filter_names;

switch (table->header.type) {
Expand All @@ -6864,9 +6864,12 @@ grn_obj_set_info_token_filters(grn_ctx *ctx,
return ctx->rc;
}

n_current_token_filters =
GRN_BULK_VSIZE(current_token_filters) / sizeof(grn_obj *);
n_token_filters = GRN_BULK_VSIZE(token_filters) / sizeof(grn_obj *);

GRN_TEXT_INIT(&token_filter_names, 0);
GRN_BULK_REWIND(current_token_filters);
n_token_filters = GRN_BULK_VSIZE(token_filters) / sizeof(grn_obj *);
for (i = 0; i < n_token_filters; i++) {
grn_obj *token_filter = GRN_PTR_VALUE_AT(token_filters, i);
char token_filter_name[GRN_TABLE_MAX_KEY_SIZE];
Expand All @@ -6883,9 +6886,11 @@ grn_obj_set_info_token_filters(grn_ctx *ctx,
token_filter_name,
token_filter_name_size);
}
GRN_LOG(ctx, GRN_LOG_NOTICE, "DDL:set_token_filters %.*s",
(int)GRN_BULK_VSIZE(&token_filter_names),
GRN_BULK_HEAD(&token_filter_names));
if (n_token_filters > 0 || n_token_filters != n_current_token_filters) {
GRN_LOG(ctx, GRN_LOG_NOTICE, "DDL:set_token_filters %.*s",
(int)GRN_BULK_VSIZE(&token_filter_names),
GRN_BULK_HEAD(&token_filter_names));
}
GRN_OBJ_FIN(ctx, &token_filter_names);
grn_obj_spec_save(ctx, DB_OBJ(table));

Expand Down

0 comments on commit ae29322

Please sign in to comment.