Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

faster shiftNRuneBytes #305

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,19 +483,17 @@ func (n *node) findCaseInsensitivePath(path string, fixTrailingSlash bool) (fixe
}

// Shift bytes in array by n bytes left
func shiftNRuneBytes(rb [4]byte, n int) [4]byte {
switch n {
case 0:
func shiftNRuneBytes(rb [4]byte, n int) (res [4]byte) {
if n == 0 {
return rb
case 1:
return [4]byte{rb[1], rb[2], rb[3], 0}
case 2:
return [4]byte{rb[2], rb[3]}
case 3:
return [4]byte{rb[3]}
default:
return [4]byte{}
} else if n == 1 {
res[0], res[1], res[2] = rb[1], rb[2], rb[3]
} else if n == 2 {
res[0], res[1] = rb[2], rb[3]
} else if n == 3 {
res[0] = rb[3]
}
return
}

// Recursive case-insensitive lookup function used by n.findCaseInsensitivePath
Expand Down