From bd2679c647de9745dc6c138520d0bf9eca751ef3 Mon Sep 17 00:00:00 2001 From: Artur Melanchyk <13834276+arturmelanchyk@users.noreply.github.com> Date: Sat, 1 Nov 2025 19:59:30 +0100 Subject: [PATCH] perf(tree): reduce allocations in findCaseInsensitivePath --- tree.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tree.go b/tree.go index bcc83502..d03d4431 100644 --- a/tree.go +++ b/tree.go @@ -671,12 +671,7 @@ walk: // Outer loop for walking the tree func (n *node) findCaseInsensitivePath(path string, fixTrailingSlash bool) ([]byte, bool) { const stackBufSize = 128 - // Use a static sized buffer on the stack in the common case. - // If the path is too long, allocate a buffer on the heap instead. - buf := make([]byte, 0, stackBufSize) - if length := len(path) + 1; length > stackBufSize { - buf = make([]byte, 0, length) - } + buf := make([]byte, 0, max(stackBufSize, len(path)+1)) ciPath := n.findCaseInsensitivePathRec( path,