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

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.

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

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

Copy link
Collaborator

@iliabylich iliabylich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 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
@iliabylich
Copy link
Collaborator

@marcandre 2.7.1.2 has been released.

@marcandre
Copy link
Contributor Author

Thank you 😸

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

Successfully merging this pull request may close these issues.

None yet

2 participants