Skip to content

Commit 036d296

Browse files
authored
Merge pull request #430 from testwill/copy
chore: use copy(to, from) instead of a loop
2 parents 36ed1c5 + 88e0e4f commit 036d296

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
@@ -188,9 +188,7 @@ func (s *state) GetVolumeByName(volName string) (Volume, error) {
188188

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

@@ -235,9 +233,7 @@ func (s *state) GetSnapshotByName(name string) (Snapshot, error) {
235233

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

0 commit comments

Comments
 (0)