-
-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Memoize Site#site_data
#6809
Conversation
lib/jekyll/site.rb
Outdated
@@ -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 |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
!
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 😃
@jekyllbot: merge +dev |
Site#site_data
is called twice per page / document when the popular pluginjekyll-seo-tag
is usedjekyll-seo-tag
is loaded by default via recent releases of Minima