Skip to content

Commit

Permalink
fts: If handed limit, stop filtering beyond that point
Browse files Browse the repository at this point in the history
  • Loading branch information
fingon committed May 3, 2024
1 parent d53e95b commit a460daf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ func filterFTS[T FTSMatchable](s []T, search string, limit int) []T {
for _, o := range s {
if o.MatchesFTS(search) {
filtered = append(filtered, o)
if len(filtered) == limit {
// We won't reuse the filtered result
// anyway, so going beyond limit won't
// be useful
break
}
}
}
return filtered
Expand Down

0 comments on commit a460daf

Please sign in to comment.