Skip to content

Commit c729db3

Browse files
MohitVachhaniMohit Vachhani
andauthored
fix: samples, cOpy -> copy (samber#279)
Co-authored-by: Mohit Vachhani <[email protected]>
1 parent 4a1a233 commit c729db3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

find.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,20 +352,20 @@ func Sample[T any](collection []T) T {
352352
func Samples[T any](collection []T, count int) []T {
353353
size := len(collection)
354354

355-
cOpy := append([]T{}, collection...)
355+
copy := append([]T{}, collection...)
356356

357357
results := []T{}
358358

359359
for i := 0; i < size && i < count; i++ {
360360
copyLength := size - i
361361

362362
index := rand.Intn(size - i)
363-
results = append(results, cOpy[index])
363+
results = append(results, copy[index])
364364

365365
// Removes element.
366366
// It is faster to swap with last element and remove it.
367-
cOpy[index] = cOpy[copyLength-1]
368-
cOpy = cOpy[:copyLength-1]
367+
copy[index] = copy[copyLength-1]
368+
copy = copy[:copyLength-1]
369369
}
370370

371371
return results

0 commit comments

Comments
 (0)