[Groonga-commit] groonga/grngo at 17d5748 [master] Replace if-blocks with switch-cases.

Back to archive index

susumu.yata null+****@clear*****
Wed Jun 24 18:16:26 JST 2015


susumu.yata	2015-06-24 18:16:26 +0900 (Wed, 24 Jun 2015)

  New Revision: 17d5748cc2c23ae74d96064d0fbe86501c13bc87
  https://github.com/groonga/grngo/commit/17d5748cc2c23ae74d96064d0fbe86501c13bc87

  Message:
    Replace if-blocks with switch-cases.

  Modified files:
    grngo.go

  Modified: grngo.go (+20 -22)
===================================================================
--- grngo.go    2015-06-24 17:01:43 +0900 (abb9801)
+++ grngo.go    2015-06-24 18:16:26 +0900 (15f6d22)
@@ -425,31 +425,29 @@ func (db *DB) CreateTable(name string, options *TableOptions) (*Table, error) {
 	if (options.Flags & KeyWithSIS) == KeyWithSIS {
 		optionsMap["flags"] += "|KEY_WITH_SIS"
 	}
-	if options.KeyType != "" {
-		switch options.KeyType {
-		case "Bool", "Int8", "Int16", "Int32", "Int64", "UInt8", "UInt16",
-			"UInt32", "UInt64", "Float", "Time", "ShortText", "TokyoGeoPoint",
-			"WGS84GeoPoint":
-			optionsMap["key_type"] = options.KeyType
-		default:
-			if _, err := db.FindTable(options.KeyType); err != nil {
-				return nil, fmt.Errorf("unsupported key type: options = %+v", options)
-			}
-			optionsMap["key_type"] = options.KeyType
+	switch options.KeyType {
+	case "":
+	case "Bool", "Int8", "Int16", "Int32", "Int64", "UInt8", "UInt16",
+		"UInt32", "UInt64", "Float", "Time", "ShortText", "TokyoGeoPoint",
+		"WGS84GeoPoint":
+		optionsMap["key_type"] = options.KeyType
+	default:
+		if _, err := db.FindTable(options.KeyType); err != nil {
+			return nil, fmt.Errorf("invalid key type: options = %+v", options)
 		}
+		optionsMap["key_type"] = options.KeyType
 	}
-	if options.ValueType != "" {
-		switch options.ValueType {
-		case "Bool", "Int8", "Int16", "Int32", "Int64", "UInt8", "UInt16",
-			"UInt32", "UInt64", "Float", "Time", "TokyoGeoPoint", "WGS84GeoPoint":
-			optionsMap["value_type"] = options.ValueType
-		default:
-			if _, err := db.FindTable(options.ValueType); err != nil {
-				return nil, fmt.Errorf("unsupported value type: options = %+v",
-					options)
-			}
-			optionsMap["value_type"] = options.ValueType
+	switch options.ValueType {
+	case "":
+	case "Bool", "Int8", "Int16", "Int32", "Int64", "UInt8", "UInt16",
+		"UInt32", "UInt64", "Float", "Time", "TokyoGeoPoint", "WGS84GeoPoint":
+		optionsMap["value_type"] = options.ValueType
+	default:
+		if _, err := db.FindTable(options.ValueType); err != nil {
+			return nil, fmt.Errorf("invalid value type: options = %+v",
+				options)
 		}
+		optionsMap["value_type"] = options.ValueType
 	}
 	if options.DefaultTokenizer != "" {
 		optionsMap["default_tokenizer"] = options.DefaultTokenizer
-------------- next part --------------
HTML����������������������������...
Download 



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