seekLines scans contentLines looking for a contiguous subsequence that matches searchLines according to the provided `eq` function. It returns the start and end (exclusive) indices into contentLines of the match.
(contentLines, searchLines []string, eq func(a, b string) bool)
| 1438 | // searchLines according to the provided `eq` function. It returns the start and |
| 1439 | // end (exclusive) indices into contentLines of the match. |
| 1440 | func seekLines(contentLines, searchLines []string, eq func(a, b string) bool) (start, end int, ok bool) { |
| 1441 | if len(searchLines) == 0 { |
| 1442 | return 0, 0, true |
| 1443 | } |
| 1444 | if len(searchLines) > len(contentLines) { |
| 1445 | return 0, 0, false |
| 1446 | } |
| 1447 | outer: |
| 1448 | for i := 0; i <= len(contentLines)-len(searchLines); i++ { |
| 1449 | for j, sLine := range searchLines { |
| 1450 | if !eq(contentLines[i+j], sLine) { |
| 1451 | continue outer |
| 1452 | } |
| 1453 | } |
| 1454 | return i, i + len(searchLines), true |
| 1455 | } |
| 1456 | return 0, 0, false |
| 1457 | } |
| 1458 | |
| 1459 | // countLineMatches counts how many non-overlapping contiguous |
| 1460 | // subsequences of contentLines match searchLines according to eq. |