mirror of https://github.com/Dreamacro/clash.git
Fix: use correctly last record
This commit is contained in:
parent
1a8a6d0b5d
commit
904c354ee4
|
@ -114,11 +114,11 @@ func (p *Proxy) LastDelay() (delay uint16) {
|
||||||
return max
|
return max
|
||||||
}
|
}
|
||||||
|
|
||||||
head := p.history.First()
|
last := p.history.Last()
|
||||||
if head == nil {
|
if last == nil {
|
||||||
return max
|
return max
|
||||||
}
|
}
|
||||||
history := head.(C.DelayHistory)
|
history := last.(C.DelayHistory)
|
||||||
if history.Delay == 0 {
|
if history.Delay == 0 {
|
||||||
return max
|
return max
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,16 +34,16 @@ func (q *Queue) Pop() interface{} {
|
||||||
return head
|
return head
|
||||||
}
|
}
|
||||||
|
|
||||||
// First returns the head of items without deleting.
|
// Last returns the last of item.
|
||||||
func (q *Queue) First() interface{} {
|
func (q *Queue) Last() interface{} {
|
||||||
if len(q.items) == 0 {
|
if len(q.items) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
q.lock.RLock()
|
q.lock.RLock()
|
||||||
head := q.items[0]
|
last := q.items[len(q.items)-1]
|
||||||
q.lock.RUnlock()
|
q.lock.RUnlock()
|
||||||
return head
|
return last
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy get the copy of queue.
|
// Copy get the copy of queue.
|
||||||
|
|
Loading…
Reference in New Issue