From 509d39efa096dc161ade2b492e461e5e6f28226c Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 7 Jun 2025 08:54:35 -0400 Subject: [PATCH] perf(anim): use faster PRNG --- internal/tui/components/anim/anim.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/tui/components/anim/anim.go b/internal/tui/components/anim/anim.go index 46c4156b02d148f51e8ff03afd7341354de1ad44..18585f1a82a8dadc916b0af69ad4c1f067286bf4 100644 --- a/internal/tui/components/anim/anim.go +++ b/internal/tui/components/anim/anim.go @@ -3,7 +3,7 @@ package anim import ( "fmt" "image/color" - "math/rand" + "math/rand/v2" "strings" "time" @@ -41,7 +41,7 @@ type cyclingChar struct { } func (c cyclingChar) randomRune() rune { - return (charRunes)[rand.Intn(len(charRunes))] //nolint:gosec + return (charRunes)[rand.IntN(len(charRunes))] //nolint:gosec } func (c cyclingChar) state(start time.Time) charState { @@ -137,7 +137,7 @@ func New(cyclingCharsSize uint, label string, opts ...animOption) Animation { } makeDelay := func(a int32, b time.Duration) time.Duration { - return time.Duration(rand.Int31n(a)) * (time.Millisecond * b) //nolint:gosec + return time.Duration(rand.Int32N(a)) * (time.Millisecond * b) //nolint:gosec } makeInitialDelay := func() time.Duration {