mirror of
https://github.com/walles/moar.git
synced 2024-11-30 02:34:13 +03:00
Implement more of the parallel search
This commit is contained in:
parent
27d03630a5
commit
aa342d4325
18
m/search.go
18
m/search.go
@ -55,9 +55,23 @@ func (p *Pager) findFirstHit(startPosition linenumbers.LineNumber, beforePositio
|
||||
searchStarts[i] = startPosition.NonWrappingAdd(i * chunkSize)
|
||||
}
|
||||
|
||||
// FIXME: Make a results array, with one result per chunk
|
||||
// Make a results array, with one result per chunk
|
||||
findings := make([]chan *scrollPosition, chunkCount)
|
||||
|
||||
// FIXME: Search all chunks in parallel
|
||||
// Search all chunks in parallel
|
||||
for i, searchStart := range searchStarts {
|
||||
findings[i] = make(chan *scrollPosition)
|
||||
|
||||
searchEndIndex := i + 1
|
||||
var beforePosition *linenumbers.LineNumber
|
||||
if searchEndIndex < len(searchStarts) {
|
||||
beforePosition = &searchStarts[searchEndIndex]
|
||||
}
|
||||
|
||||
go func() {
|
||||
findings[i] <- p._findFirstHit(searchStart, beforePosition, backwards)
|
||||
}()
|
||||
}
|
||||
|
||||
// FIXME: Return the first non-nil result
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user