stream/mts/meta.go: avoiding adding same key to order slice

This commit is contained in:
saxon 2019-02-05 13:11:11 +10:30
parent 834625a9f7
commit 3364b4ea6f
1 changed files with 6 additions and 0 deletions

View File

@ -80,6 +80,12 @@ func New() *Metadata {
func (m *Metadata) Add(key, val string) {
m.mu.Lock()
m.data[key] = val
for _, k := range m.order {
if k == key {
m.mu.Unlock()
return
}
}
m.order = append(m.order, key)
m.mu.Unlock()
}