mirror of
https://github.com/gin-gonic/gin.git
synced 2025-05-25 14:29:27 +08:00
chore: longestCommonPrefix func in tree.go, fix variable name and add comment
This commit is contained in:
parent
ef68fa032c
commit
fb022f54c0
6
tree.go
6
tree.go
@ -65,10 +65,12 @@ func (trees methodTrees) get(method string) *node {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// calculate the length of the longest common prefix of two strings
|
||||||
func longestCommonPrefix(a, b string) int {
|
func longestCommonPrefix(a, b string) int {
|
||||||
i := 0
|
i := 0
|
||||||
max_ := min(len(a), len(b))
|
// commonPrefixMaxLen is the min value of a and b's length.
|
||||||
for i < max_ && a[i] == b[i] {
|
commonPrefixMaxLen := min(len(a), len(b))
|
||||||
|
for i < commonPrefixMaxLen && a[i] == b[i] {
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
return i
|
return i
|
||||||
|
Loading…
x
Reference in New Issue
Block a user