Skip to content

Commit ee8a146

Browse files
committed
refactor(context): use new(make) for context slice allocation
1 parent dbfa9f0 commit ee8a146

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

tree.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,11 @@ func (t *iTree) lookupByPath(method, path string, c *Context, lazy bool) (int, *
4747
}
4848

4949
func (t *iTree) allocateContext() *Context {
50-
patterns := make([]string, 0)
51-
params := make([]string, 0, t.maxParams)
52-
keys := make([]string, 0, t.maxParams)
53-
stacks := make(skipStack, 0, t.maxDepth)
5450
return &Context{
55-
params: &params,
56-
skipStack: &stacks,
57-
paramsKeys: &keys,
58-
subPatterns: &patterns,
51+
params: new(make([]string, 0, t.maxParams)),
52+
skipStack: new(make(skipStack, 0, t.maxDepth)),
53+
paramsKeys: new(make([]string, 0, t.maxParams)),
54+
subPatterns: new(make([]string, 0)),
5955
// This is a read only value, no reset. It's always the
6056
// owner of the pool.
6157
tree: t,

0 commit comments

Comments
 (0)