Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
vc: Use map built-in accessor to find container in Sandbox#GetContainer
Browse files Browse the repository at this point in the history
Fixes #2289

Signed-off-by: Ted Yu <yuzhihong@gmail.com>
  • Loading branch information
yutedz committed Nov 29, 2019
1 parent d054556 commit 38224e8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,8 @@ func (s *Sandbox) GetAllContainers() []VCContainer {

// GetContainer returns the container named by the containerID.
func (s *Sandbox) GetContainer(containerID string) VCContainer {
for id, c := range s.containers {
if id == containerID {
return c
}
if c, ok := s.containers[containerID]; ok {
return c
}
return nil
}
Expand Down

0 comments on commit 38224e8

Please sign in to comment.