on main help sign in
perf(anim): reduce pointer dereferences
commitc519c8ed1071f3b209eef4e95d2291c44386ff57 authorChristian Rocha <christian@rocha.is> dateSat 7 Jun 2025, 08:57 (1 year ago) parent301d42f
1 file changed+5−4
internal/tui/components/anim/anim.go+5−4
internal/tui/components/anim/anim.go+5−4
@@ -226,14 +226,15 @@ func (a anim) ID() string {
226226}
227227
228228func (a *anim) updateChars(chars *[]cyclingChar) {
229− for i, c := range *chars {
229+ charSlice := *chars // dereference to avoid repeated pointer access
230+ for i, c := range charSlice {
230231 switch c.state(a.start) {
231232 case charInitialState:
232− (*chars)[i].currentValue = '.'
233+ charSlice[i].currentValue = '.'
233234 case charCyclingState:
234− (*chars)[i].currentValue = c.randomRune()
235+ charSlice[i].currentValue = c.randomRune()
235236 case charEndOfLifeState:
236− (*chars)[i].currentValue = c.finalValue
237+ charSlice[i].currentValue = c.finalValue
237238 }
238239 }
239240}