cleanup
This commit is contained in:
parent
eb6272e411
commit
39c4720e40
1 changed files with 1 additions and 22 deletions
|
|
@ -14,23 +14,6 @@ type queue []*Preload
|
|||
|
||||
func (queue) LessReverse(i, j *Preload) bool { return i.Prio > j.Prio }
|
||||
|
||||
func (q *queue) Head() (p *Preload) {
|
||||
l := len(*q)
|
||||
if l > 0 {
|
||||
p = (*q)[l-1]
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (q *queue) Pop() (p *Preload) {
|
||||
l := len(*q)
|
||||
if l > 0 {
|
||||
p = q.Head()
|
||||
*q = (*q)[:l-1]
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (q *queue) Sort() {
|
||||
slices.SortFunc(*q, q.LessReverse)
|
||||
}
|
||||
|
|
@ -43,11 +26,7 @@ func (q *queue) Add(ph *PreloadHandler, name string, prio int) {
|
|||
return
|
||||
}
|
||||
}
|
||||
q.Append(&Preload{Name: name, ph: ph})
|
||||
}
|
||||
|
||||
func (q *queue) Append(p *Preload) {
|
||||
*q = append(*q, p)
|
||||
*q = append(*q, &Preload{Name: name, ph: ph})
|
||||
q.Sort()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue