Browse Source

common: CMap: slight optimization in Keys() and Values(). (#3567)

pull/3580/head
hucc 6 years ago
committed by Anton Kaliaev
parent
commit
5b8888b01b
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      libs/common/cmap.go

+ 2
- 2
libs/common/cmap.go View File

@ -56,7 +56,7 @@ func (cm *CMap) Clear() {
func (cm *CMap) Keys() []string { func (cm *CMap) Keys() []string {
cm.l.Lock() cm.l.Lock()
keys := []string{}
keys := make([]string, 0, len(cm.m))
for k := range cm.m { for k := range cm.m {
keys = append(keys, k) keys = append(keys, k)
} }
@ -66,7 +66,7 @@ func (cm *CMap) Keys() []string {
func (cm *CMap) Values() []interface{} { func (cm *CMap) Values() []interface{} {
cm.l.Lock() cm.l.Lock()
items := []interface{}{}
items := make([]interface{}, 0, len(cm.m))
for _, v := range cm.m { for _, v := range cm.m {
items = append(items, v) items = append(items, v)
} }


Loading…
Cancel
Save