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

Memoize Site#site_data #6809

Merged
merged 2 commits into from
Mar 14, 2018
Merged

Memoize Site#site_data #6809

merged 2 commits into from
Mar 14, 2018

Conversation

ashmaroli
Copy link
Member

@ashmaroli ashmaroli commented Feb 26, 2018

  • Site#site_data is called twice per page / document when the popular plugin jekyll-seo-tag is used
  • jekyll-seo-tag is loaded by default via recent releases of Minima
  • IMO, its better addressing this here instead of patching per plugin(s)

@DirtyF DirtyF requested review from a team February 26, 2018 16:15
@@ -253,7 +253,7 @@ def categories
#
# Returns the Hash to be hooked to site.data.
def site_data
config["data"] || data
@site_data ||= config["data"] || data
Copy link
Member

Choose a reason for hiding this comment

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

If you want to memoize the ||, then it'd be: @site_data ||= (config["data"] || data). By default, this is equivalent to (@site_data ||= config["data"]) || data.

Copy link
Member

Choose a reason for hiding this comment

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

This @site_data should also be reset in reset!

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding the use of parenthesis, I did not know, this would be interpreted that way.. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

@ashmaroli You might enjoy http://tmm1.net/ruby21-profiling/ which has an example of where parentheses went awry!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I'll check it out 😃

@DirtyF DirtyF added this to the v3.8.0 milestone Mar 1, 2018
@ghost
Copy link

ghost commented Mar 14, 2018

@jekyllbot: merge +dev

@jekyllbot jekyllbot merged commit 55d64c7 into jekyll:master Mar 14, 2018
jekyllbot added a commit that referenced this pull request Mar 14, 2018
@ashmaroli ashmaroli deleted the memoize-site-data branch March 14, 2018 10:54
@jekyll jekyll locked and limited conversation to collaborators Jul 12, 2019
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.

4 participants