hugolib: Defer the unlock in orderedMap.Add

Just in case someone tries to recover from the potential panic.
This commit is contained in:
Bjørn Erik Pedersen 2018-04-22 21:32:05 +02:00
parent 474bad34ca
commit 24c662ce6b
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F

View file

@ -38,14 +38,13 @@ func newOrderedMapFromStringMapString(m map[string]string) *orderedMap {
func (m *orderedMap) Add(k, v interface{}) {
m.Lock()
defer m.Unlock()
_, found := m.m[k]
if found {
panic(fmt.Sprintf("%v already added", v))
}
m.m[k] = v
m.keys = append(m.keys, k)
m.Unlock()
}
func (m *orderedMap) Get(k interface{}) (interface{}, bool) {