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)
Upstream-commit: e963179c790ec49b28fae0d7ebc0d9d2b3ac0b72
Component: engine
This commit is contained in:
unclejack
2014-05-14 15:02:02 +03:00
parent 592230c928
commit 2809f19cbb
2 changed files with 4 additions and 0 deletions
+1
View File
@@ -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
}
+3
View File
@@ -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)
}