|
|
|
@ -6,11 +6,11 @@ type matchIndex struct {
|
|
|
|
|
endIdx int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns true if the given matchIndex is an improper subset of any of the indices in the slice.
|
|
|
|
|
// Returns true if the given matchIndex has ovelrap with any of the indices in the slice.
|
|
|
|
|
// When we add an index to our slice, we want to make sure a larger match isn't already present.
|
|
|
|
|
func overlaps(idx matchIndex, idxes []matchIndex) bool {
|
|
|
|
|
for _, val := range idxes {
|
|
|
|
|
if idx.startIdx >= val.startIdx && idx.endIdx <= val.endIdx {
|
|
|
|
|
if (idx.startIdx > val.startIdx && idx.startIdx < val.endIdx) || (idx.endIdx > val.startIdx && idx.endIdx < val.endIdx) {
|
|
|
|
|
// A zero-length match doesn't overlap if it is located at the start or end
|
|
|
|
|
// of the other match
|
|
|
|
|
if !(idx.startIdx == idx.endIdx && (idx.startIdx == val.startIdx || idx.startIdx == val.endIdx)) {
|
|
|
|
|