Avoid unnecessary calls to Container.Spec()
This call does a deep copy, which is only needed if you want to modify the return value. Instead we use ctr.ConfigNoCopy().Spec which is just a pointer dereference. [NO NEW TESTS NEEDED] Just minor performance effects Signed-off-by: Alexander Larsson <alexl@redhat.com>
This commit is contained in:
parent
55191ecc20
commit
af38c79e36
|
@ -474,7 +474,7 @@ func ConfigToSpec(rt *libpod.Runtime, specg *specgen.SpecGenerator, contaierID s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
specg.OverlayVolumes = overlay
|
specg.OverlayVolumes = overlay
|
||||||
_, mounts := c.SortUserVolumes(c.Spec())
|
_, mounts := c.SortUserVolumes(c.ConfigNoCopy().Spec)
|
||||||
specg.Mounts = mounts
|
specg.Mounts = mounts
|
||||||
specg.HostDeviceList = conf.DeviceHostSrc
|
specg.HostDeviceList = conf.DeviceHostSrc
|
||||||
specg.Networks = conf.Networks
|
specg.Networks = conf.Networks
|
||||||
|
|
|
@ -288,7 +288,7 @@ func getVolumesFrom(volumesFrom []string, runtime *libpod.Runtime) (map[string]s
|
||||||
|
|
||||||
// Now we get the container's spec and loop through its volumes
|
// Now we get the container's spec and loop through its volumes
|
||||||
// and append them in if we can find them.
|
// and append them in if we can find them.
|
||||||
spec := ctr.Spec()
|
spec := ctr.ConfigNoCopy().Spec
|
||||||
if spec == nil {
|
if spec == nil {
|
||||||
return nil, nil, fmt.Errorf("retrieving container %s spec for volumes-from", ctr.ID())
|
return nil, nil, fmt.Errorf("retrieving container %s spec for volumes-from", ctr.ID())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue