mirror of https://github.com/gin-gonic/gin.git
chore(tree): replace the self-defined 'min' to official one (#3975)
This commit is contained in:
parent
24d67647cb
commit
334160bab7
15
tree.go
15
tree.go
|
@ -65,17 +65,10 @@ func (trees methodTrees) get(method string) *node {
|
|||
return nil
|
||||
}
|
||||
|
||||
func min(a, b int) int {
|
||||
if a <= b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func longestCommonPrefix(a, b string) int {
|
||||
i := 0
|
||||
max := min(len(a), len(b))
|
||||
for i < max && a[i] == b[i] {
|
||||
max_ := min(len(a), len(b))
|
||||
for i < max_ && a[i] == b[i] {
|
||||
i++
|
||||
}
|
||||
return i
|
||||
|
@ -205,7 +198,7 @@ walk:
|
|||
}
|
||||
|
||||
// Check if a child with the next path byte exists
|
||||
for i, max := 0, len(n.indices); i < max; i++ {
|
||||
for i, max_ := 0, len(n.indices); i < max_; i++ {
|
||||
if c == n.indices[i] {
|
||||
parentFullPathIndex += len(n.path)
|
||||
i = n.incrementChildPrio(i)
|
||||
|
@ -770,7 +763,7 @@ walk: // Outer loop for walking the tree
|
|||
// Runes are up to 4 byte long,
|
||||
// -4 would definitely be another rune.
|
||||
var off int
|
||||
for max := min(npLen, 3); off < max; off++ {
|
||||
for max_ := min(npLen, 3); off < max_; off++ {
|
||||
if i := npLen - off; utf8.RuneStart(oldPath[i]) {
|
||||
// read rune from cached path
|
||||
rv, _ = utf8.DecodeRuneInString(oldPath[i:])
|
||||
|
|
Loading…
Reference in New Issue