fix: map 其桶中只能存储 8 个键值对元素,超过后会储存到溢出桶或者扩容,影响性能,预先声明容量以免影响性能 (#1671)

pull/1681/head
kiripeng 3 years ago committed by GitHub
parent 413cc77f7d
commit 041ffffb15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      contrib/registry/nacos/registry.go

@ -97,11 +97,11 @@ func (r *Registry) Register(ctx context.Context, si *registry.ServiceInstance) e
return err return err
} }
if si.Metadata == nil { if si.Metadata == nil {
si.Metadata = make(map[string]string) si.Metadata = make(map[string]string, 2)
} }
si.Metadata["kind"] = u.Scheme si.Metadata["kind"] = u.Scheme
si.Metadata["version"] = si.Version si.Metadata["version"] = si.Version
rmd := make(map[string]string) rmd := make(map[string]string, len(si.Metadata))
for k, v := range si.Metadata { for k, v := range si.Metadata {
rmd[k] = v rmd[k] = v
} }

Loading…
Cancel
Save