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

Reduce array allocations from StaticFile#path #8083

Merged
merged 3 commits into from Mar 30, 2020

Conversation

ashmaroli
Copy link
Member

Summary

Jekyll::StaticFile#path involves duplicating arrays via Array#Compact. So multiple calls to the unmemoized method would result in unnecessary Array allocations.

@ashmaroli ashmaroli added the micro-optimization Matters only if it is a very large site ¯\_(ツ)_/¯ label Mar 30, 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.

Any possible side-effect due to memoization? Not sure if our tests would catch those.

@ashmaroli
Copy link
Member Author

In theory, a resource's (irrespective of page, document, static-file, layout, etc) path shouldn't change. Additionally, for static-files, there is no equivalent writer (:path=). So, it can be assumed to be a read-only attribute.

If at all something is mutating the path attribute, then that code should be fixed.

@ashmaroli
Copy link
Member Author

Should I freeze the attribute value and see if something breaks / fails..?

@DirtyF
Copy link
Member

DirtyF commented Mar 30, 2020

As you see fit, just want to make sure we don't ship any regression, or that we don't miss any test here 😅

@ashmaroli
Copy link
Member Author

Note: I'll unfreeze the attribute value after some testing..

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.

Thanks Ashwin.

@DirtyF
Copy link
Member

DirtyF commented Mar 30, 2020

@jekyllbot: merge +fix

@jekyllbot jekyllbot merged commit f0ab099 into jekyll:master Mar 30, 2020
jekyllbot added a commit that referenced this pull request Mar 30, 2020
@DirtyF DirtyF removed the bug label Mar 30, 2020
@ashmaroli ashmaroli deleted the memoize-static-file-path branch March 30, 2020 14:46
@jekyll jekyll locked and limited conversation to collaborators Mar 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fix frozen-due-to-age micro-optimization Matters only if it is a very large site ¯\_(ツ)_/¯
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants