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

Enable Performance/ChainArrayAllocation cop #8404

Merged
merged 5 commits into from
Sep 30, 2020

Conversation

ashmaroli
Copy link
Member

Summary

RuboCop Performance has a cop that allows detecting method chains that duplicate starting array with each chain segment.
But the cop is disabled by default.

This pull request enables the cop and fixes offenses reported by it by switching non-mutating methods with mutating counterparts.

@jekyll jekyll deleted a comment from RamboCacing666 Sep 20, 2020
Copy link
Member

@DirtyF DirtyF left a comment

Choose a reason for hiding this comment

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

Tests pass, looks like it's safe to mutate in those methods.
The gain is hard to notice in our test suite.

@ashmaroli
Copy link
Member Author

ashmaroli commented Sep 21, 2020

Thanks for the review @DirtyF :)
When you say The gain is hard to notice.., if you meant speed-wise, then yeah, this is a micro-optimization. Any speed gain will be shadowed by a drain elsewhere. However, if you meant allocation-wise, our docs site is a small sample. The third-party repo workflow shows an approx. gain of 2MB.

That said, I'll wait to see if @parkr or @mattr- sees something we missed or overlooked

Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

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

This is looking good! I left a couple comments about some optimizations we might be able to make here.

lib/jekyll/drops/drop.rb Show resolved Hide resolved
lib/jekyll/filters/url_filters.rb Show resolved Hide resolved
lib/jekyll/page.rb Outdated Show resolved Hide resolved
lib/jekyll/renderer.rb Outdated Show resolved Hide resolved
@ashmaroli ashmaroli marked this pull request as draft September 25, 2020 04:56
@ashmaroli
Copy link
Member Author

Requires #8408 to be reviewed and merged first...

@ashmaroli ashmaroli marked this pull request as ready for review September 30, 2020 06:46
@ashmaroli
Copy link
Member Author

@jekyllbot: merge +fix

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

Successfully merging this pull request may close these issues.

None yet

4 participants