MCPcopy Create free account
hub / github.com/BryanMwangi/pine / longestCommonPrefix

Function longestCommonPrefix

router.go:275–286  ·  view source on GitHub ↗

longestCommonPrefix returns the length of the shared prefix between a and b.

(a, b string)

Source from the content-addressed store, hash-verified

273
274// longestCommonPrefix returns the length of the shared prefix between a and b.
275func longestCommonPrefix(a, b string) int {
276 max := len(a)
277 if len(b) < max {
278 max = len(b)
279 }
280 for i := 0; i < max; i++ {
281 if a[i] != b[i] {
282 return i
283 }
284 }
285 return max
286}
287
288// buildParams zips paramNames with captured values into a map.
289func buildParams(names, values []string) map[string]string {

Callers 1

insertMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected