From 730e0994c8ceec64e753562c648e57e0a7ead6b4 Mon Sep 17 00:00:00 2001 From: Ma Shimiao Date: Wed, 14 Dec 2016 17:34:29 +0800 Subject: [PATCH] oci/namespace: remove unnecessary variable idx Signed-off-by: Ma Shimiao --- oci/namespaces.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/oci/namespaces.go b/oci/namespaces.go index 4902482498..ebea76bfbb 100644 --- a/oci/namespaces.go +++ b/oci/namespaces.go @@ -4,13 +4,10 @@ import specs "github.com/opencontainers/runtime-spec/specs-go" // RemoveNamespace removes the `nsType` namespace from OCI spec `s` func RemoveNamespace(s *specs.Spec, nsType specs.NamespaceType) { - idx := -1 for i, n := range s.Linux.Namespaces { if n.Type == nsType { - idx = i + s.Linux.Namespaces = append(s.Linux.Namespaces[:i], s.Linux.Namespaces[i+1:]...) + return } } - if idx >= 0 { - s.Linux.Namespaces = append(s.Linux.Namespaces[:idx], s.Linux.Namespaces[idx+1:]...) - } }