Skip to content

Commit bd2679c

Browse files
perf(tree): reduce allocations in findCaseInsensitivePath
1 parent 2e22e50 commit bd2679c

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

tree.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,12 +671,7 @@ walk: // Outer loop for walking the tree
671671
func (n *node) findCaseInsensitivePath(path string, fixTrailingSlash bool) ([]byte, bool) {
672672
const stackBufSize = 128
673673

674-
// Use a static sized buffer on the stack in the common case.
675-
// If the path is too long, allocate a buffer on the heap instead.
676-
buf := make([]byte, 0, stackBufSize)
677-
if length := len(path) + 1; length > stackBufSize {
678-
buf = make([]byte, 0, length)
679-
}
674+
buf := make([]byte, 0, max(stackBufSize, len(path)+1))
680675

681676
ciPath := n.findCaseInsensitivePathRec(
682677
path,

0 commit comments

Comments
 (0)