[Groonga-commit] groonga/groonga at e104c8f [master] load: extract common codes

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Aug 27 17:33:49 JST 2018


Kouhei Sutou	2018-08-27 17:33:49 +0900 (Mon, 27 Aug 2018)

  Revision: e104c8fb094aea1dead8080895d9f65b765e3f4c
  https://github.com/groonga/groonga/commit/e104c8fb094aea1dead8080895d9f65b765e3f4c

  Message:
    load: extract common codes

  Modified files:
    lib/load.c

  Modified: lib/load.c (+18 -10)
===================================================================
--- lib/load.c    2018-08-27 17:28:26 +0900 (56c9a5a1d)
+++ lib/load.c    2018-08-27 17:33:49 +0900 (9c8a898f5)
@@ -309,6 +309,22 @@ parse_id_value(grn_ctx *ctx, grn_obj *value)
 }
 
 static void
+grn_loader_apply_each(grn_ctx *ctx,
+                      grn_loader *loader,
+                      grn_id id)
+{
+  grn_obj *var;
+
+  if (!loader->each) {
+    return;
+  }
+
+  var = grn_expr_get_var_by_offset(ctx, loader->each, 0);
+  GRN_RECORD_SET(ctx, var, id);
+  grn_expr_exec(ctx, loader->each, 0);
+}
+
+static void
 bracket_close_set_values(grn_ctx *ctx,
                          grn_loader *loader,
                          grn_id id,
@@ -516,11 +532,7 @@ bracket_close(grn_ctx *ctx, grn_loader *loader)
   }
 
   bracket_close_set_values(ctx, loader, id, key, value, nvalues);
-  if (loader->each) {
-    grn_obj *v = grn_expr_get_var_by_offset(ctx, loader->each, 0);
-    GRN_RECORD_SET(ctx, v, id);
-    grn_expr_exec(ctx, loader->each, 0);
-  }
+  grn_loader_apply_each(ctx, loader, id);
   loader->nrecords++;
 exit:
   if (is_record_load) {
@@ -711,11 +723,7 @@ brace_close(grn_ctx *ctx, grn_loader *loader)
   }
 
   brace_close_set_values(ctx, loader, id, key, value_begin, value_end);
-  if (loader->each) {
-    value = grn_expr_get_var_by_offset(ctx, loader->each, 0);
-    GRN_RECORD_SET(ctx, value, id);
-    grn_expr_exec(ctx, loader->each, 0);
-  }
+  grn_loader_apply_each(ctx, loader, id);
   loader->nrecords++;
 exit:
   if (ctx->rc != GRN_SUCCESS) {
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180827/51246c6c/attachment-0001.htm 



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