refactor(web): relocate definition of .sourceRangeKey to SearchQuotientSpur, SearchQuotientNode 🚂#15103
Conversation
User Test ResultsTest specification and instructions User tests are not required |
804e5d7 to
20c6f10
Compare
807c09d to
45ad85a
Compare
7831a6d to
346f737
Compare
346f737 to
a6d4180
Compare
a6d4180 to
3a19b06
Compare
27fc7da to
025c1f4
Compare
3a19b06 to
01371c0
Compare
025c1f4 to
ba97ea7
Compare
01371c0 to
a679ebe
Compare
fda509c to
3a613df
Compare
…ntSpur, SearchQuotientNode Build-bot: skip build:web Test-bot: skip
cb6ffee to
cf39508
Compare
web/src/engine/predictive-text/worker-thread/src/main/correction/search-quotient-spur.ts
Outdated
Show resolved
Hide resolved
| */ | ||
| get sourceRangeKey(): string { | ||
| const components: string[] = []; | ||
| const sources = this.inputSegments; |
There was a problem hiding this comment.
(GH won't let me put a comment on the function because it didn't change, so I'm putting it here:)
Nothing new, but devin.ai noticed that inputSegments getter has side effects and mutates this.parentNode.inputSegments.
To work around we could replace parentSources.push(this.inputSource); with parentSources = [...parentSources, this.inputSource];
There was a problem hiding this comment.
I don't see any actual side-effects unless a new type with a different implementation of the getter is created (that maintains a single root instance that is reused).
The array is dynamically built on each and every call; it's not re-used in between calls and is built-up recursively. Note the common recursive root return value - a fresh, empty array is the base recursive frame for each call.
If I have two instances of SearchQuotientNode - say, A and B, with A serving as B's parent...
const bSegments = b.inputSegments;
const aSegments = a.inputSegments;
will be two separate instances.
…efactor/web/relocate-source-range-key
The
.sourceRangeKeyproperty previously defined onContextTokenwill be very useful for validating certain conditions needed for the upcomingSearchQuotientClusterimplementation ofSearchQuotientNode. AsContextTokenownsSearchQuotientNodes, and not the other way around, establishing it as a member ofSearchQuotientNodeprovides better, more direct access for the new upcoming use-case.Build-bot: skip build:web
Test-bot: skip