Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove early return limit from KMP search
  • Loading branch information
midzer committed Feb 26, 2025
commit c83360315a995f2e5ae0b810af90d5a579a2af7a
7 changes: 1 addition & 6 deletions src/scripts/search/kmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,10 @@ function kmpSearch(pattern: string, text: string): number {
export class SearchByKMP<T extends object> implements Searcher<T> {
_fields: string[];

_limit: number;

_haystack: T[] = [];

constructor(config: Options) {
this._fields = config.searchFields;
this._limit = config.searchResultLimit;
}

index(data: T[]): void {
Expand Down Expand Up @@ -80,9 +77,7 @@ export class SearchByKMP<T extends object> implements Searcher<T> {
score: count,
rank: count + 1,
});
if (++count === this._limit) {
return results;
}
count++;
}
}
}
Expand Down