Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/@glimmer/validator/lib/tracked-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ export class TrackedValue<Value = unknown> implements Reactive<Value> {
readonly #tag: UpdatableTag;

constructor(value: Value, options: ReactiveOptions<Value>) {
/**
* If we let V8 try to completely optimize TrackedValue for
* for each type of `value`,
* that performs worse than making V8 only use one internal
* internal version of the class for each type of `value`.
*
* The first value of another kind makes V8 throw away
* the optimized code that reads the field.
*
* The field starts as `undefined`,
* so a number here makes it general from the first instance.
*/
this.#value = 0 as Value;
this.#value = value;
this.#options = options;
this.#tag = createUpdatableTag();
Expand Down
Loading