event: initialize maps with known size (#27233)

event: initialize maps with known size
This commit is contained in:
ucwong 2023-05-09 13:29:32 -06:00 committed by GitHub
parent c62da24dce
commit 0fb1be0930
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,7 +61,7 @@ func (mux *TypeMux) Subscribe(types ...interface{}) *TypeMuxSubscription {
close(sub.postC) close(sub.postC)
} else { } else {
if mux.subm == nil { if mux.subm == nil {
mux.subm = make(map[reflect.Type][]*TypeMuxSubscription) mux.subm = make(map[reflect.Type][]*TypeMuxSubscription, len(types))
} }
for _, t := range types { for _, t := range types {
rtyp := reflect.TypeOf(t) rtyp := reflect.TypeOf(t)