From c6e492313beedbd6ea8abfc55ebaa99d684c44c0 Mon Sep 17 00:00:00 2001 From: Joshua Horton Date: Mon, 16 Feb 2026 09:34:00 +0700 Subject: [PATCH] fix(web): add code, comment fixes from PR review --- .../src/main/correction/search-quotient-cluster.ts | 12 +++++++++--- .../src/main/correction/search-quotient-spur.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-cluster.ts b/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-cluster.ts index 54b285f69c..33b025e3a6 100644 --- a/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-cluster.ts +++ b/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-cluster.ts @@ -195,9 +195,15 @@ export class SearchQuotientCluster implements SearchQuotientNode { return false; } - // We need to check if the parents match. Done naively in the manner below, this is O(N^2). - // Granted, we shouldn't have _that_ many incoming paths. - if(this.parents.find((path) => !space.parents.find((path2) => path.isSameNode(path2)))) { + // We need to check if the parents match. + // First, is the parent count the same? + if(this.parents.length != space.parents.length) { + return false; + } else if (this.parents.find((path) => !space.parents.find((path2) => path.isSameNode(path2)))) { + // Done naively in the manner above, checking each pair of nodes, to + // ensure a match is found for each, is O(N^2). + // + // Granted, we shouldn't have _that_ many incoming paths. return false; } diff --git a/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-spur.ts b/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-spur.ts index 034aab1ddd..e30e99ff75 100644 --- a/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-spur.ts +++ b/web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-spur.ts @@ -497,7 +497,7 @@ export abstract class SearchQuotientSpur implements SearchQuotientNode { } isSameNode(space: SearchQuotientNode): boolean { - // Easiest cases: when the instances or their ' `spaceId` matches, we have + // Easiest cases: when the instances or their `spaceId` matches, we have // a perfect match. if(this == space || this.spaceId == space.spaceId) { return true;