mirror of
https://github.com/ent/ent.git
synced 2026-04-28 05:30:56 +03:00
go: small refactoring for maps (#2619)
This commit is contained in:
@@ -246,10 +246,10 @@ type graphScope struct {
|
||||
// {{ end}}
|
||||
//
|
||||
func extend(v interface{}, kv ...interface{}) (interface{}, error) {
|
||||
scope := make(map[interface{}]interface{})
|
||||
if len(kv)%2 != 0 {
|
||||
return nil, fmt.Errorf("invalid number of parameters: %d", len(kv))
|
||||
}
|
||||
scope := make(map[interface{}]interface{}, len(kv)/2)
|
||||
for i := 0; i < len(kv); i += 2 {
|
||||
scope[kv[i]] = kv[i+1]
|
||||
}
|
||||
|
||||
@@ -63,10 +63,10 @@ func (a Annotation) Merge(other schema.Annotation) schema.Annotation {
|
||||
default:
|
||||
return a
|
||||
}
|
||||
if a.StructTag == nil && len(ant.StructTag) > 0 {
|
||||
a.StructTag = make(map[string]string, len(ant.StructTag))
|
||||
}
|
||||
for k, v := range ant.StructTag {
|
||||
if a.StructTag == nil {
|
||||
a.StructTag = make(map[string]string)
|
||||
}
|
||||
a.StructTag[k] = v
|
||||
}
|
||||
if len(ant.ID) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user