]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
tpl/collections: Require collections.D args to be ints
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 4 Sep 2025 09:18:39 +0000 (11:18 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 4 Sep 2025 12:01:51 +0000 (14:01 +0200)
Fixes #13952

Co-authored-by: Joe Mooring <joe.mooring@veriphor.com>
tpl/collections/collections.go

index 1447a3fab6659bfd59c59f6b12385d2c69621643..b678f0c1ee5833b2b809151002f76396d5e3bf74 100644 (file)
@@ -539,8 +539,8 @@ type dKey struct {
 // using  J. S. Vitter's Method D for sequential random sampling, from Vitter, J.S.
 // - An Efficient Algorithm for Sequential Random Sampling - ACM Trans. Math. Software 11 (1985), 37-57.
 // See  https://getkerf.wordpress.com/2016/03/30/the-best-algorithm-no-one-knows-about/
-func (ns *Namespace) D(seed, n, hi any) []int {
-       key := dKey{seed: cast.ToUint64(seed), n: cast.ToInt(n), hi: cast.ToInt(hi)}
+func (ns *Namespace) D(seed, n, hi int) []int {
+       key := dKey{seed: cast.ToUint64(seed), n: n, hi: hi}
        if key.n <= 0 || key.hi <= 0 || key.n > key.hi {
                return nil
        }