[WIP] implement bitmask-based change tracking #1943
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Just some test output for now — manually tweaked all the
expected.js
files to help me think about the problem a bit more. Couple of takeaways:changed === 0
then we can skip updates altogether, which means that if an update is happening then that single reactive value definitely has changedchanged
is therefore an optional argument toupdate
functions, the order of arguments should be reversed —(ctx, changed) => {...}
rather than(changed, ctx) => {...}
— so that we can omit it where possible.n & -1
is only0
whenn === 0
(in fact, for integers up to a certain size,n & -1 === n
). This gives us an easy way to say 'everything changed,' e.g. when initialising reactive declarationsWe might be able to use that insight to reduce duplication between create and update code. If you have a template like this...
...that expression is output twice:
Usually we're not duplicating code as contrived as that, but it's a problem nonetheless. A neater version would look like this:
I had a run that problem a while back but it proved too difficult, particularly around instantiating nested components. It might be easier now.
Also, at present, the
$$dirty
object passed into the reactive declaration update block (which is the same aschanged
elsewhere; we should make that consistent) is conveniently mutable, which means that sequential updates work:Here,
$$dirty.b
is true because of the$$invalidate('b', b)
right before it. If$$dirty
isn't an object that would no longer work. So I guess we'd need to do this instead: