MCPcopy Create free account
hub / github.com/sergi/go-diff / commonPrefixLength

Function commonPrefixLength

diffmatchpatch/diff.go:433–442  ·  view source on GitHub ↗

commonPrefixLength returns the length of the common prefix of two rune slices.

(text1, text2 []rune)

Source from the content-addressed store, hash-verified

431
432// commonPrefixLength returns the length of the common prefix of two rune slices.
433func commonPrefixLength(text1, text2 []rune) int {
434 // Linear search. See comment in commonSuffixLength.
435 n := 0
436 for ; n < len(text1) && n < len(text2); n++ {
437 if text1[n] != text2[n] {
438 return n
439 }
440 }
441 return n
442}
443
444// commonSuffixLength returns the length of the common suffix of two rune slices.
445func commonSuffixLength(text1, text2 []rune) int {

Callers 6

diffMainRunesMethod · 0.85
DiffCommonPrefixMethod · 0.85
diffHalfMatchIMethod · 0.85
DiffCleanupMergeMethod · 0.85
TestCommonPrefixLengthFunction · 0.85
BenchmarkCommonLengthFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestCommonPrefixLengthFunction · 0.68
BenchmarkCommonLengthFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…