Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions middleware/body_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,7 @@ func (w *limitedWriter) Write(b []byte) (n int, err error) {
// Write to dump buffer only up to limit
if w.dumped < w.limit {
remaining := w.limit - w.dumped
toDump := int64(n)
if toDump > remaining {
toDump = remaining
}
toDump := min(int64(n), remaining)
w.dumpBuf.Write(b[:toDump])
w.dumped += toDump
}
Expand Down
10 changes: 2 additions & 8 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,7 @@ func (r *DefaultRouter) insert(t kind, path string, method string, ri routeMetho
lcpLen := 0

// LCP - Longest Common Prefix (https://en.wikipedia.org/wiki/LCP_array)
maxL := prefixLen
if searchLen < maxL {
maxL = searchLen
}
maxL := min(searchLen, prefixLen)
for ; lcpLen < maxL && search[lcpLen] == currentNode.prefix[lcpLen]; lcpLen++ {
}

Expand Down Expand Up @@ -867,10 +864,7 @@ func (r *DefaultRouter) Route(c *Context) HandlerFunc {
prefixLen = len(currentNode.prefix)

// LCP - Longest Common Prefix (https://en.wikipedia.org/wiki/LCP_array)
lMax := prefixLen
if searchLen < lMax {
lMax = searchLen
}
lMax := min(searchLen, prefixLen)
for ; lcpLen < lMax && search[lcpLen] == currentNode.prefix[lcpLen]; lcpLen++ {
}
}
Expand Down
Loading