event: initialize maps with known size #27233 (#1550)

Co-authored-by: ucwong <ucwong@126.com>
This commit is contained in:
Daniel Liu 2025-09-24 07:47:54 +08:00 committed by GitHub
parent 6c73723f47
commit 53b3431af5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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