on main help sign in
perf(anim): reduce pointer dereferences
c519c8eChristian Rocha
internal/tui/components/anim/anim.go+5−4
@@ -226,14 +226,15 @@ func (a anim) ID() string {
226}
226}
227
227
228func (a *anim) updateChars(chars *[]cyclingChar) {
228func (a *anim) updateChars(chars *[]cyclingChar) {
229+ charSlice := *chars // dereference to avoid repeated pointer access
229− for i, c := range *chars {
230+ for i, c := range charSlice {
230 switch c.state(a.start) {
231 switch c.state(a.start) {
231 case charInitialState:
232 case charInitialState:
232− (*chars)[i].currentValue = '.'
233+ charSlice[i].currentValue = '.'
233 case charCyclingState:
234 case charCyclingState:
234− (*chars)[i].currentValue = c.randomRune()
235+ charSlice[i].currentValue = c.randomRune()
235 case charEndOfLifeState:
236 case charEndOfLifeState:
236− (*chars)[i].currentValue = c.finalValue
237+ charSlice[i].currentValue = c.finalValue
237 }
238 }
238 }
239 }
239}
240}