[Groonga-mysql-commit] mroonga/mroonga [master] Swap if/else clauses to use positive condition in if expression

Back to archive index

null+****@clear***** null+****@clear*****
2012年 5月 28日 (月) 23:45:13 JST


Kouhei Sutou	2012-05-28 23:45:13 +0900 (Mon, 28 May 2012)

  New Revision: ae13b574a6be9c12f362b17fbdff8edf939d1172

  Log:
    Swap if/else clauses to use positive condition in if expression

  Modified files:
    ha_mroonga.cpp

  Modified: ha_mroonga.cpp (+14 -14)
===================================================================
--- ha_mroonga.cpp    2012-05-28 23:43:39 +0900 (9390323)
+++ ha_mroonga.cpp    2012-05-28 23:45:13 +0900 (1612927)
@@ -2695,7 +2695,10 @@ int ha_mroonga::storage_create_index(TABLE *table, const char *grn_table_name,
   grn_obj_flags index_table_flags = GRN_OBJ_PERSISTENT;
   grn_obj_flags index_column_flags =
     GRN_OBJ_COLUMN_INDEX | GRN_OBJ_WITH_POSITION | GRN_OBJ_PERSISTENT;
-  if (!is_multiple_column_index) {
+  if (is_multiple_column_index) {
+    index_type = grn_ctx_at(ctx, GRN_DB_SHORT_TEXT);
+    index_column_flags |= GRN_OBJ_WITH_SECTION;
+  } else {
     Field *field = key_info->key_part[0].field;
     const char *column_name = field->field_name;
     int column_name_size = strlen(column_name);
@@ -2708,9 +2711,6 @@ int ha_mroonga::storage_create_index(TABLE *table, const char *grn_table_name,
     column = grn_obj_column(ctx, grn_table, column_name, column_name_size);
     grn_builtin_type groonga_type = mrn_grn_type_from_field(ctx, field, true);
     index_type = grn_ctx_at(ctx, groonga_type);
-  } else {
-    index_type = grn_ctx_at(ctx, GRN_DB_SHORT_TEXT);
-    index_column_flags |= GRN_OBJ_WITH_SECTION;
   }
 
   int key_alg = key_info->algorithm;
@@ -2773,16 +2773,7 @@ int ha_mroonga::storage_create_index(TABLE *table, const char *grn_table_name,
   }
 
   mrn_change_encoding(ctx, system_charset_info);
-  if (!is_multiple_column_index) {
-    if (column) {
-      grn_obj source_ids;
-      grn_id source_id = grn_obj_id(ctx, column);
-      GRN_UINT32_INIT(&source_ids, GRN_OBJ_VECTOR);
-      GRN_UINT32_PUT(ctx, &source_ids, source_id);
-      grn_obj_set_info(ctx, index_column, GRN_INFO_SOURCE, &source_ids);
-      grn_obj_unlink(ctx, &source_ids);
-    }
-  } else {
+  if (is_multiple_column_index) {
     if (key_info->flags & HA_FULLTEXT) {
       grn_obj source_ids;
       GRN_UINT32_INIT(&source_ids, GRN_OBJ_VECTOR);
@@ -2801,6 +2792,15 @@ int ha_mroonga::storage_create_index(TABLE *table, const char *grn_table_name,
       grn_obj_set_info(ctx, index_column, GRN_INFO_SOURCE, &source_ids);
       grn_obj_unlink(ctx, &source_ids);
     }
+  } else {
+    if (column) {
+      grn_obj source_ids;
+      grn_id source_id = grn_obj_id(ctx, column);
+      GRN_UINT32_INIT(&source_ids, GRN_OBJ_VECTOR);
+      GRN_UINT32_PUT(ctx, &source_ids, source_id);
+      grn_obj_set_info(ctx, index_column, GRN_INFO_SOURCE, &source_ids);
+      grn_obj_unlink(ctx, &source_ids);
+    }
   }
 
   index_tables[i] = index_table;




Groonga-mysql-commit メーリングリストの案内
Back to archive index