[Groonga-commit] groonga/groonga at 027c296 [master] string: immediate return for error case

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Feb 1 10:42:59 JST 2016


Kouhei Sutou	2016-02-01 10:42:59 +0900 (Mon, 01 Feb 2016)

  New Revision: 027c296bca0797d55785b871e368eee926d9a7fd
  https://github.com/groonga/groonga/commit/027c296bca0797d55785b871e368eee926d9a7fd

  Message:
    string: immediate return for error case

  Modified files:
    plugins/functions/string.c

  Modified: plugins/functions/string.c (+9 -14)
===================================================================
--- plugins/functions/string.c    2016-02-01 10:41:20 +0900 (a32b23f)
+++ plugins/functions/string.c    2016-02-01 10:42:59 +0900 (df8495f)
@@ -38,18 +38,7 @@ func_string_length(grn_ctx *ctx, int n_args, grn_obj **args,
   }
 
   target = args[0];
-  switch (target->header.type) {
-  case GRN_BULK :
-    {
-      const char *s = GRN_TEXT_VALUE(target);
-      const char *e = GRN_TEXT_VALUE(target) + GRN_TEXT_LEN(target);
-      const char *p;
-      unsigned int cl = 0;
-      for (p = s; p < e && (cl = grn_charlen(ctx, p, e)); p += cl, length++);
-    }
-    break;
-  default :
-    {
+  if (target->header.type != GRN_BULK) {
       grn_obj inspected;
 
       GRN_TEXT_INIT(&inspected, 0);
@@ -60,8 +49,14 @@ func_string_length(grn_ctx *ctx, int n_args, grn_obj **args,
                        GRN_TEXT_VALUE(&inspected));
       GRN_OBJ_FIN(ctx, &inspected);
       return NULL;
-    }
-    break;
+  }
+
+  {
+    const char *s = GRN_TEXT_VALUE(target);
+    const char *e = GRN_TEXT_VALUE(target) + GRN_TEXT_LEN(target);
+    const char *p;
+    unsigned int cl = 0;
+    for (p = s; p < e && (cl = grn_charlen(ctx, p, e)); p += cl, length++);
   }
 
   grn_length = grn_plugin_proc_alloc(ctx, user_data, GRN_DB_UINT32, 0);
-------------- next part --------------
HTML����������������������������...
Download 



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