[Groonga-commit] groonga/grngo at 03d72cf [master] Simplify grngo_table_get_key_info().

Back to archive index

susumu.yata null+****@clear*****
Fri Jul 10 16:15:59 JST 2015


susumu.yata	2015-07-10 16:15:59 +0900 (Fri, 10 Jul 2015)

  New Revision: 03d72cfd179f86ae21538131f9ff34be33632a86
  https://github.com/groonga/grngo/commit/03d72cfd179f86ae21538131f9ff34be33632a86

  Message:
    Simplify grngo_table_get_key_info().

  Modified files:
    grngo.c

  Modified: grngo.c (+14 -23)
===================================================================
--- grngo.c    2015-07-10 16:14:36 +0900 (5023446)
+++ grngo.c    2015-07-10 16:15:59 +0900 (4318943)
@@ -57,31 +57,22 @@ grn_rc grngo_table_get_key_info(grn_ctx *ctx, grn_obj *table,
     return GRN_INVALID_ARGUMENT;
   }
   grngo_table_type_info_init(key_info);
-  switch (table->header.type) {
-    case GRN_TABLE_HASH_KEY:
-    case GRN_TABLE_PAT_KEY:
-    case GRN_TABLE_DAT_KEY: {
-      if (table->header.domain <= GRNGO_MAX_BUILTIN_TYPE_ID) {
-        key_info->data_type = table->header.domain;
-        return GRN_SUCCESS;
-      }
-      grn_obj *ref_table = grn_ctx_at(ctx, table->header.domain);
-      if (!ref_table || !grn_obj_is_table(ctx, ref_table)) {
-        if (ctx->rc != GRN_SUCCESS) {
-          return ctx->rc;
-        }
-        return GRN_UNKNOWN_ERROR;
-      }
-      key_info->ref_table = ref_table;
-      return GRN_SUCCESS;
-    }
-    case GRN_TABLE_NO_KEY: {
-      return GRN_SUCCESS;
-    }
-    default: {
-      return GRN_UNKNOWN_ERROR;
+  if (table->header.type == GRN_TABLE_NO_KEY) {
+    return GRN_SUCCESS;
+  }
+  if (table->header.domain <= GRNGO_MAX_BUILTIN_TYPE_ID) {
+    key_info->data_type = table->header.domain;
+    return GRN_SUCCESS;
+  }
+  grn_obj *ref_table = grn_ctx_at(ctx, table->header.domain);
+  if (!ref_table || !grn_obj_is_table(ctx, ref_table)) {
+    if (ctx->rc != GRN_SUCCESS) {
+      return ctx->rc;
     }
+    return GRN_UNKNOWN_ERROR;
   }
+  key_info->ref_table = ref_table;
+  return GRN_SUCCESS;
 }
 
 grn_rc grngo_table_get_value_info(grn_ctx *ctx, grn_obj *table,
-------------- next part --------------
HTML����������������������������...
Download 



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