Skip to content

Commit 276e400

Browse files
committed
pre-allocate handlers when using getGroups
1 parent 8867958 commit 276e400

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/handler_mapping.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ func (m *handlerMappings) getGroups() [][]Handler {
9191
m.mutex.RLock()
9292
defer m.mutex.RUnlock()
9393

94-
var handlers [][]Handler
95-
for _, num := range m.handlerGroups {
96-
handlers = append(handlers, m.handlers[num])
94+
allHandlers := make([][]Handler, len(m.handlerGroups))
95+
for idx, num := range m.handlerGroups {
96+
allHandlers[idx] = m.handlers[num]
9797
}
98-
return handlers
98+
return allHandlers
9999
}

0 commit comments

Comments
 (0)