mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 15:42:01 +03:00
perf: optimize registry phrase addition string allocations
Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
parent
bede889ced
commit
13fa559536
1 changed files with 6 additions and 1 deletions
|
|
@ -88,7 +88,12 @@ export class Registry {
|
|||
const list = this.byFirst.get(key);
|
||||
if (list) {
|
||||
// first registration of an identical phrase wins (core vocab is added first)
|
||||
if (list.some((e) => e.caseSensitive === caseSensitive && (caseSensitive ? e.lexemes.join(" ") === lexemes.join(" ") : e.lower.join(" ") === entry.lower.join(" ")))) {
|
||||
if (list.some((e) => {
|
||||
if (e.caseSensitive !== caseSensitive || e.lexemes.length !== lexemes.length) return false;
|
||||
const target = caseSensitive ? lexemes : entry.lower;
|
||||
const source = caseSensitive ? e.lexemes : e.lower;
|
||||
return source.every((val, i) => val === target[i]);
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
list.push(entry);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue