mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-20 05:54:34 -04:00
style(tracker): clean up Alerts Push and Pop
This commit is contained in:
parent
4f2c73d0db
commit
f47bee37b0
@ -96,15 +96,17 @@ func (m *Alerts) AddAlert(a Alert) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Alerts) Push(x any) {
|
func (m *Alerts) Push(x any) {
|
||||||
|
if _, ok := x.(Alert); !ok {
|
||||||
|
panic("invalid type for Alerts.Push, expected Alert")
|
||||||
|
}
|
||||||
m.alerts = append(m.alerts, x.(Alert))
|
m.alerts = append(m.alerts, x.(Alert))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Alerts) Pop() any {
|
func (m *Alerts) Pop() any {
|
||||||
old := m.alerts
|
n := len(m.alerts)
|
||||||
n := len(old)
|
last := m.alerts[n-1]
|
||||||
x := old[n-1]
|
m.alerts = m.alerts[:n-1]
|
||||||
m.alerts = old[0 : n-1]
|
return last
|
||||||
return x
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Alerts) Len() int { return len(m.alerts) }
|
func (m Alerts) Len() int { return len(m.alerts) }
|
||||||
|
Reference in New Issue
Block a user