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.
After implementing #14, I've been wondering if that could cause memory issues. I can think of some memory leaks caused by deliberate behavior, but I also think that in most cases it should not cause user-perceivable problems.
Still, I don't like that approach, saving the value on each link makes me feel insecure. Finally I discovered that we can have a
push-pull-push model solution that doesn't use version/value at all.
The new push-pull-push model is very similar to the approach adopted by vuejs/core#5912.
In this method, we don't need to use intermediate variables to detect changes, because all flag updates are immediate as needed.
Memory Usage improvement
Since Link does not need to store value, the memory usage is reduced by 3% (2434.72KB -> 2363.90KB) in the following test.
Benchmark Results
main bench
1.43 µs/iter
1.42 µs
1.43 µs
1.45 µs
1.45 µs
7.40 µs/iter
7.38 µs
7.41 µs
7.42 µs
7.42 µs
65.68 µs/iter
64.79 µs
65.58 µs
69.79 µs
101.50 µs
12.85 µs/iter
12.84 µs
12.85 µs
12.85 µs
12.85 µs
72.23 µs/iter
71.38 µs
72.13 µs
75.88 µs
104.50 µs
653.37 µs/iter
649.33 µs
654.33 µs
673.13 µs
703.71 µs
126.44 µs/iter
125.21 µs
126.17 µs
134.21 µs
156.04 µs
717.02 µs/iter
712.42 µs
717.71 µs
741.50 µs
765.29 µs
6.51 ms/iter
6.49 ms
6.51 ms
6.60 ms
6.61 ms
This PR
1.43 µs/iter
1.42 µs
1.43 µs
1.44 µs
1.47 µs
7.17 µs/iter
7.14 µs
7.18 µs
7.19 µs
7.20 µs
63.22 µs/iter
63.15 µs
63.25 µs
63.26 µs
63.31 µs
12.78 µs/iter
12.77 µs
12.79 µs
12.79 µs
12.79 µs
70.18 µs/iter
69.38 µs
70.00 µs
75.04 µs
95.21 µs
640.52 µs/iter
630.67 µs
644.63 µs
653.75 µs
674.08 µs
125.57 µs/iter
124.13 µs
125.33 µs
136.38 µs
155.38 µs
697.68 µs/iter
693.50 µs
698.25 µs
720.67 µs
755.00 µs
6.32 ms/iter
6.30 ms
6.32 ms
6.38 ms
6.44 ms