perf: remove listener directly from once emit instead of using off function

new-emitter
TorchedSammy 2022-08-02 15:09:23 -04:00
parent a6f53b3c43
commit c76337e5a4
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 2 additions and 2 deletions

View File

@ -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)
} }
} }
} }