@@ -34,16 +34,16 @@ export class SearchQuotientSpur implements SearchQuotientNode {
3434 readonly spaceId : number ;
3535
3636 /**
37- * Marks all results that have already been returned since the last input was received .
38- * Is cleared after .addInput() calls .
37+ * Marks all results that have already been returned from this instance of SearchPath .
38+ * Should be deleted and cleared if any paths consider this one as a parent .
3939 */
4040 private returnedValues ?: { [ resultKey : string ] : SearchNode } = { } ;
4141
4242 /**
43- * Provides a heuristic for the base cost at each depth if the best
44- * individual input were taken at that level .
43+ * Provides a heuristic for the base cost at this path's depth if the best
44+ * individual input were taken here, regardless of whether or not that's possible .
4545 */
46- private lowestCostAtDepth : number [ ] ;
46+ readonly lowestPossibleSingleCost : number ;
4747
4848 /**
4949 * Constructs a fresh SearchSpace instance for used in predictive-text correction
@@ -61,7 +61,7 @@ export class SearchQuotientSpur implements SearchQuotientNode {
6161 const logTierCost = - Math . log ( bestProbFromSet ) ;
6262
6363 this . inputs = inputs ;
64- this . lowestCostAtDepth = parentNode . lowestCostAtDepth . concat ( logTierCost ) ;
64+ this . lowestPossibleSingleCost = parentNode . lowestPossibleSingleCost + logTierCost ;
6565 this . parentPath = parentNode ;
6666
6767 this . addEdgesForNodes ( parentNode . previousResults . map ( v => v . node ) ) ;
@@ -71,7 +71,7 @@ export class SearchQuotientSpur implements SearchQuotientNode {
7171
7272 const model = arg1 as LexicalModel ;
7373 this . selectionQueue . enqueue ( new SearchNode ( model . traverseFromRoot ( ) , this . spaceId , t => model . toKey ( t ) ) ) ;
74- this . lowestCostAtDepth = [ ] ;
74+ this . lowestPossibleSingleCost = 0 ;
7575 }
7676
7777 /**
@@ -202,8 +202,7 @@ export class SearchQuotientSpur implements SearchQuotientNode {
202202 // ... or even just not the then-current layer of the keyboard.
203203 //
204204 // TODO: still consider the lowest-cost individual edges for THIS specific criterion.
205- const tierMinCost = this . lowestCostAtDepth [ currentNode . priorInput . length - 1 ] ;
206- if ( currentNode . currentCost > tierMinCost + 2.5 * EDIT_DISTANCE_COST_SCALE ) {
205+ if ( currentNode . currentCost > this . lowestPossibleSingleCost + 2.5 * EDIT_DISTANCE_COST_SCALE ) {
207206 return unmatchedResult ;
208207 }
209208
0 commit comments