* Pre-compile word-boundary regexes for all search terms. * Called once per search instead of tools×terms×2 times.
(terms: string[])
| 165 | * Called once per search instead of tools×terms×2 times. |
| 166 | */ |
| 167 | function compileTermPatterns(terms: string[]): Map<string, RegExp> { |
| 168 | const patterns = new Map<string, RegExp>() |
| 169 | for (const term of terms) { |
| 170 | if (!patterns.has(term)) { |
| 171 | patterns.set(term, new RegExp(`\\b${escapeRegExp(term)}\\b`)) |
| 172 | } |
| 173 | } |
| 174 | return patterns |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Keyword-based search over tool names and descriptions. |
no test coverage detected