mirror of
https://github.com/Hilbis/Hilbish
synced 2025-04-21 04:53:24 +00:00
perf: remove listener directly from once emit instead of using off function
This commit is contained in:
parent
a6f53b3c43
commit
c76337e5a4
@ -48,7 +48,7 @@ func (b *Bait) Emit(event string, args ...interface{}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, handle := range handles {
|
for idx, handle := range handles {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
b.callRecoverer(event, handle, err)
|
b.callRecoverer(event, handle, err)
|
||||||
@ -77,7 +77,7 @@ func (b *Bait) Emit(event string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if handle.once {
|
if handle.once {
|
||||||
b.Off(event, handle)
|
b.removeListener(event, idx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user