Skip to content

Commit 88e0e4f

Browse files
committed
chore: use copy(to, from) instead of a loop
1 parent 0048ab7 commit 88e0e4f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

pkg/state/state.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ func (s *state) GetVolumeByName(volName string) (Volume, error) {
189189

190190
func (s *state) GetVolumes() []Volume {
191191
volumes := make([]Volume, len(s.Volumes))
192-
for i, volume := range s.Volumes {
193-
volumes[i] = volume
194-
}
192+
copy(volumes, s.Volumes)
195193
return volumes
196194
}
197195

@@ -236,9 +234,7 @@ func (s *state) GetSnapshotByName(name string) (Snapshot, error) {
236234

237235
func (s *state) GetSnapshots() []Snapshot {
238236
snapshots := make([]Snapshot, len(s.Snapshots))
239-
for i, snapshot := range s.Snapshots {
240-
snapshots[i] = snapshot
241-
}
237+
copy(snapshots, s.Snapshots)
242238
return snapshots
243239
}
244240

0 commit comments

Comments
 (0)