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:
Alexander Larsson
2022-10-12 10:18:07 +02:00
parent 55191ecc20
commit af38c79e36
2 changed files with 2 additions and 2 deletions

View File

@ -474,7 +474,7 @@ func ConfigToSpec(rt *libpod.Runtime, specg *specgen.SpecGenerator, contaierID s
}
}
specg.OverlayVolumes = overlay
_, mounts := c.SortUserVolumes(c.Spec())
_, mounts := c.SortUserVolumes(c.ConfigNoCopy().Spec)
specg.Mounts = mounts
specg.HostDeviceList = conf.DeviceHostSrc
specg.Networks = conf.Networks

View File

@ -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
// and append them in if we can find them.
spec := ctr.Spec()
spec := ctr.ConfigNoCopy().Spec
if spec == nil {
return nil, nil, fmt.Errorf("retrieving container %s spec for volumes-from", ctr.ID())
}