tests: broaden fixture corpus quality coverage#17
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0305735ba0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| while searchStart < lowercaseText.endIndex, | ||
| let range = lowercaseText.range(of: term, range: searchStart..<lowercaseText.endIndex) { | ||
| locations.append(lowercaseText.distance(from: lowercaseText.startIndex, to: range.lowerBound)) |
There was a problem hiding this comment.
Avoid quadratic index-distance scans in term location loop
The new compactness scorer makes every .allTerms query walk each matching document body via termLocations, and this loop computes distance(from: startIndex, to:) for every hit. On long texts with frequent terms (for example, a common word appearing thousands of times), those repeated distance calculations accumulate to roughly O(n²) work per term, which can make in-memory search latency spike substantially compared with the previous constant-time scoring path. Converting the search text to a random-access representation once (or tracking offsets incrementally) avoids this regression.
Useful? React with 👍 / 👎.
Summary
Verification