diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []index.
(text string, lineArray *[]string, lineHash map[string]int, lineCount int)
| 1352 | |
| 1353 | // diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []index. |
| 1354 | func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]string, lineHash map[string]int, lineCount int) []index { |
| 1355 | lineStart := 0 |
| 1356 | lineEnd := -1 |
| 1357 | strs := make([]index, 0, lineCount) |
| 1358 | |
| 1359 | for lineEnd < len(text)-1 { |
| 1360 | lineEnd = indexOf(text, "\n", lineStart) |
| 1361 | |
| 1362 | if lineEnd == -1 { |
| 1363 | lineEnd = len(text) - 1 |
| 1364 | } |
| 1365 | |
| 1366 | line := text[lineStart : lineEnd+1] |
| 1367 | lineStart = lineEnd + 1 |
| 1368 | lineValue, ok := lineHash[line] |
| 1369 | |
| 1370 | if ok { |
| 1371 | strs = append(strs, index(lineValue)) |
| 1372 | } else { |
| 1373 | *lineArray = append(*lineArray, line) |
| 1374 | lineHash[line] = len(*lineArray) - 1 |
| 1375 | strs = append(strs, index(len(*lineArray)-1)) |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | return strs |
| 1380 | } |
no test coverage detected