Skip to content

Refactor TextEditor updating #244

Merged
aminya merged 38 commits intomasterfrom
text-editor-update-dispatch
Oct 31, 2020
Merged

Refactor TextEditor updating #244
aminya merged 38 commits intomasterfrom
text-editor-update-dispatch

Conversation

@aminya
Copy link
Member

@aminya aminya commented Oct 30, 2020

Description of the change

This PR refactors the codes that were responsible for updating different parts of TextEditor out of update function, and, then, it uses those refactored functions directly, which bypasses the loop and switch case inside update.

finishUpdate is 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 update to 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

  • Refactor the codes that were responsible for updating different parts of TextEditor

@aminya aminya added the enhancement New feature or request label Oct 30, 2020
@aminya aminya force-pushed the text-editor-update-dispatch branch 2 times, most recently from 3a351c8 to 26904d9 Compare October 30, 2020 10:56
@aminya aminya force-pushed the text-editor-update-dispatch branch from 26904d9 to 1fad43d Compare October 30, 2020 11:06
@aminya aminya force-pushed the text-editor-update-dispatch branch from 1fad43d to 6df8e77 Compare October 31, 2020 01:18
@aminya aminya merged commit 1d66db1 into master Oct 31, 2020
@aminya
Copy link
Member Author

aminya commented Oct 31, 2020

Upstreamed atom#21620

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant