mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
don't call sort for every add in history
This moves the call to sort in daemon/history to a function to be called explicitly when we're done adding elements to the list. This speeds up `docker ps`. Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
This commit is contained in:
parent
f637eaca5d
commit
e963179c79
2 changed files with 4 additions and 0 deletions
|
@ -85,6 +85,7 @@ func (daemon *Daemon) List() []*Container {
|
|||
for e := daemon.containers.Front(); e != nil; e = e.Next() {
|
||||
containers.Add(e.Value.(*Container))
|
||||
}
|
||||
containers.Sort()
|
||||
return *containers
|
||||
}
|
||||
|
||||
|
|
|
@ -26,5 +26,8 @@ func (history *History) Swap(i, j int) {
|
|||
|
||||
func (history *History) Add(container *Container) {
|
||||
*history = append(*history, container)
|
||||
}
|
||||
|
||||
func (history *History) Sort() {
|
||||
sort.Sort(history)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue