Skip to content

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 kata-containers#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.