stream/mts/meta/meta.go: using defer for m.mu.Unlock() Meta.Add()

This commit is contained in:
saxon 2019-02-05 23:25:46 +10:30
parent 6b32064a2b
commit cf73c853b0
1 changed files with 2 additions and 2 deletions

View File

@ -79,15 +79,15 @@ func New() *Metadata {
// Add adds metadata with key and val.
func (m *Metadata) Add(key, val string) {
m.mu.Lock()
defer m.mu.Unlock()
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()
return
}
// All returns the a copy of the map containing the meta data.