Merged
Conversation
3a351c8 to
26904d9
Compare
26904d9 to
1fad43d
Compare
1fad43d to
6df8e77
Compare
Member
Author
|
Upstreamed atom#21620 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of the change
This PR refactors the codes that were responsible for updating different parts of TextEditor out of
updatefunction, and, then, it uses those refactored functions directly, which bypasses the loop and switch case insideupdate.finishUpdateis also refactored that allows finishing updating of TextEditor from inside themselves without the need for creating objects outside and passing them in.Benefits
This reduces the complexity of the update algorithm for those that are updated directly (
O(n^2)->O(1)). This removes the overhead of checking for the given value against the keys in switch-case, and it also removes the overhead of the for-loop. Directly calling these functions is similar to the compile-time method dispatch used in other languages like C++. The previous method was a runtime dispatch algorithm that does not allow the V8 engine to optimize these calls and indirections.Having these functions separate makes it easier to maintain, find, and reason about them.
Verification
I have moved the code inside
updateto a separate function as it is (exact copy-paste), and I have not changed "any part of the actual code". If you follow my commits one by one, you will see that the moved code is kept exactly identical.All the tests must pass because this does not change the functionality.
Release Notes