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

Method diffLinesToStrings

diffmatchpatch/diff.go:1322–1331  ·  view source on GitHub ↗

diffLinesToStrings splits two texts into a list of strings. Each string represents one line.

(text1, text2 string)

Source from the content-addressed store, hash-verified

1320
1321// diffLinesToStrings splits two texts into a list of strings. Each string represents one line.
1322func (dmp *DiffMatchPatch) diffLinesToStrings(text1, text2 string) (string, string, []string) {
1323 lineArray := []string{""} // e.g. lineArray[4] == 'Hello\n'
1324
1325 lineHash := make(map[string]int)
1326 //Each string has the index of lineArray which it points to
1327 strIndexArray1 := dmp.diffLinesToStringsMunge(text1, &lineArray, lineHash)
1328 strIndexArray2 := dmp.diffLinesToStringsMunge(text2, &lineArray, lineHash)
1329
1330 return intArrayToString(strIndexArray1), intArrayToString(strIndexArray2), lineArray
1331}
1332
1333// diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []index.
1334func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]string, lineHash map[string]int) []index {

Callers 2

DiffLinesToCharsMethod · 0.95
DiffLinesToRunesMethod · 0.95

Calls 2

intArrayToStringFunction · 0.85

Tested by

no test coverage detected