mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
common: CMap: slight optimization in Keys() and Values(). (#3567)
This commit is contained in:
parent
439312b9c0
commit
5b8888b01b
@ -56,7 +56,7 @@ func (cm *CMap) Clear() {
|
||||
func (cm *CMap) Keys() []string {
|
||||
cm.l.Lock()
|
||||
|
||||
keys := []string{}
|
||||
keys := make([]string, 0, len(cm.m))
|
||||
for k := range cm.m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
@ -66,7 +66,7 @@ func (cm *CMap) Keys() []string {
|
||||
|
||||
func (cm *CMap) Values() []interface{} {
|
||||
cm.l.Lock()
|
||||
items := []interface{}{}
|
||||
items := make([]interface{}, 0, len(cm.m))
|
||||
for _, v := range cm.m {
|
||||
items = append(items, v)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user