Revert the use of the slices.Clone function
because it does not return nil when the slice length is 0. This behavior caused the slices.Clone function to allocate a unnecessary amount of memory when the slice length is 0, and the c/common tests failed. Signed-off-by: Jan Rodák <hony.com@seznam.cz>
This commit is contained in:
parent
9dc388169a
commit
5537f8ab2d
|
|
@ -164,11 +164,11 @@ type containerStore struct {
|
|||
func copyContainer(c *Container) *Container {
|
||||
return &Container{
|
||||
ID: c.ID,
|
||||
Names: slices.Clone(c.Names),
|
||||
Names: copyStringSlice(c.Names),
|
||||
ImageID: c.ImageID,
|
||||
LayerID: c.LayerID,
|
||||
Metadata: c.Metadata,
|
||||
BigDataNames: slices.Clone(c.BigDataNames),
|
||||
BigDataNames: copyStringSlice(c.BigDataNames),
|
||||
BigDataSizes: maps.Clone(c.BigDataSizes),
|
||||
BigDataDigests: maps.Clone(c.BigDataDigests),
|
||||
Created: c.Created,
|
||||
|
|
|
|||
10
images.go
10
images.go
|
|
@ -183,13 +183,13 @@ func copyImage(i *Image) *Image {
|
|||
return &Image{
|
||||
ID: i.ID,
|
||||
Digest: i.Digest,
|
||||
Digests: slices.Clone(i.Digests),
|
||||
Names: slices.Clone(i.Names),
|
||||
NamesHistory: slices.Clone(i.NamesHistory),
|
||||
Digests: copyDigestSlice(i.Digests),
|
||||
Names: copyStringSlice(i.Names),
|
||||
NamesHistory: copyStringSlice(i.NamesHistory),
|
||||
TopLayer: i.TopLayer,
|
||||
MappedTopLayers: slices.Clone(i.MappedTopLayers),
|
||||
MappedTopLayers: copyStringSlice(i.MappedTopLayers),
|
||||
Metadata: i.Metadata,
|
||||
BigDataNames: slices.Clone(i.BigDataNames),
|
||||
BigDataNames: copyStringSlice(i.BigDataNames),
|
||||
BigDataSizes: maps.Clone(i.BigDataSizes),
|
||||
BigDataDigests: maps.Clone(i.BigDataDigests),
|
||||
Created: i.Created,
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ func layerLocation(l *Layer) layerLocations {
|
|||
func copyLayer(l *Layer) *Layer {
|
||||
return &Layer{
|
||||
ID: l.ID,
|
||||
Names: slices.Clone(l.Names),
|
||||
Names: copyStringSlice(l.Names),
|
||||
Parent: l.Parent,
|
||||
Metadata: l.Metadata,
|
||||
MountLabel: l.MountLabel,
|
||||
|
|
@ -451,7 +451,7 @@ func copyLayer(l *Layer) *Layer {
|
|||
CompressionType: l.CompressionType,
|
||||
ReadOnly: l.ReadOnly,
|
||||
volatileStore: l.volatileStore,
|
||||
BigDataNames: slices.Clone(l.BigDataNames),
|
||||
BigDataNames: copyStringSlice(l.BigDataNames),
|
||||
Flags: maps.Clone(l.Flags),
|
||||
UIDMap: copyIDMap(l.UIDMap),
|
||||
GIDMap: copyIDMap(l.GIDMap),
|
||||
|
|
|
|||
2
store.go
2
store.go
|
|
@ -1611,7 +1611,7 @@ func (s *store) CreateImage(id string, names []string, layer, metadata string, i
|
|||
CreationDate: i.Created,
|
||||
Digest: i.Digest,
|
||||
Digests: copyDigestSlice(i.Digests),
|
||||
NamesHistory: slices.Clone(i.NamesHistory),
|
||||
NamesHistory: copyStringSlice(i.NamesHistory),
|
||||
}
|
||||
for _, key := range i.BigDataNames {
|
||||
data, err := store.BigData(id, key)
|
||||
|
|
|
|||
Loading…
Reference in New Issue