perf(schema): avoid redundant strings.ToLower call
This commit is contained in:
		
							parent
							
								
									8e7ab46c1b
								
							
						
					
					
						commit
						411946278a
					
				| @ -318,9 +318,10 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if val, ok := field.TagSettings["TYPE"]; ok { | 	if val, ok := field.TagSettings["TYPE"]; ok { | ||||||
| 		switch DataType(strings.ToLower(val)) { | 		lowerVal := DataType(strings.ToLower(val)) | ||||||
|  | 		switch lowerVal { | ||||||
| 		case Bool, Int, Uint, Float, String, Time, Bytes: | 		case Bool, Int, Uint, Float, String, Time, Bytes: | ||||||
| 			field.DataType = DataType(strings.ToLower(val)) | 			field.DataType = lowerVal | ||||||
| 		default: | 		default: | ||||||
| 			field.DataType = DataType(val) | 			field.DataType = DataType(val) | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -763,8 +763,9 @@ func (rel *Relationship) ToQueryConditions(ctx context.Context, reflectValue ref | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func copyableDataType(str DataType) bool { | func copyableDataType(str DataType) bool { | ||||||
|  | 	lowerStr := strings.ToLower(string(str)) | ||||||
| 	for _, s := range []string{"auto_increment", "primary key"} { | 	for _, s := range []string{"auto_increment", "primary key"} { | ||||||
| 		if strings.Contains(strings.ToLower(string(str)), s) { | 		if strings.Contains(lowerStr, s) { | ||||||
| 			return false | 			return false | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 1911860538
						1911860538