diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []index.
(text string, lineArray *[]string, lineHash map[string]int)
| 1332 | |
| 1333 | // diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []index. |
| 1334 | func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]string, lineHash map[string]int) []index { |
| 1335 | lineStart := 0 |
| 1336 | lineEnd := -1 |
| 1337 | strs := []index{} |
| 1338 | |
| 1339 | for lineEnd < len(text)-1 { |
| 1340 | lineEnd = indexOf(text, "\n", lineStart) |
| 1341 | |
| 1342 | if lineEnd == -1 { |
| 1343 | lineEnd = len(text) - 1 |
| 1344 | } |
| 1345 | |
| 1346 | line := text[lineStart : lineEnd+1] |
| 1347 | lineStart = lineEnd + 1 |
| 1348 | lineValue, ok := lineHash[line] |
| 1349 | |
| 1350 | if ok { |
| 1351 | strs = append(strs, index(lineValue)) |
| 1352 | } else { |
| 1353 | *lineArray = append(*lineArray, line) |
| 1354 | lineHash[line] = len(*lineArray) - 1 |
| 1355 | strs = append(strs, index(len(*lineArray)-1)) |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | return strs |
| 1360 | } |
no test coverage detected