Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewriter optimizations #683

Merged
merged 2 commits into from Apr 29, 2020
Merged

Conversation

@marcandre
Copy link
Contributor

marcandre commented Apr 29, 2020

This PR contains two independent optimizations for the Source::TreeRewriter.

The first one changes building the tree from O(n^2) to O(n log(n)) where n is the number of rewriting actions.

The second one is of lesser importance and changes applying the tree from O(n * s) to O(n + s), where s is the length of the source.

While I doubt users of RuboCop will notice the speedup but this will make a big difference for the conversion and annotation of source files into HTML by DeepCover which was ridiculously slow for long source files.

marcandre added 2 commits Apr 28, 2020
Changes algorithm from `O(n^2)` to `O(n log(n))` where `n` is the order of rewriting actions
This changes the rewriting from `O(n * s)` to `O(n + s)`, where `n` is the number of rewriting actions and `s` is the length of the source
@marcandre
Copy link
Contributor Author

marcandre commented Apr 29, 2020

PS: A release when this is merged would be appreciated 😸 . Thanks

Copy link
Collaborator

iliabylich left a comment

👍 I don't see any difference on CI in terms of speed, but I think it's ok

@iliabylich iliabylich merged commit 18f8239 into whitequark:master Apr 29, 2020
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@iliabylich
Copy link
Collaborator

iliabylich commented Apr 29, 2020

@marcandre 2.7.1.2 has been released.

@marcandre
Copy link
Contributor Author

marcandre commented Apr 30, 2020

Thank you 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.