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 string allocations from the link tag #8387

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

ashmaroli
Copy link
Member

  • This is a 🔨 code refactoring.

Summary

Currently with the link tag, we have a string interpolation inside an iteration block:

site.each_site_file do |item|
return relative_url(item) if item.relative_path == relative_path
# This takes care of the case for static files that have a leading /
return relative_url(item) if item.relative_path == "/#{relative_path}"
end

In a site with lots of files, the string interpolation on L#28 can result in a lot of unnecessary String allocations especially if the link tag is rendered in multiple pages.

The simplest solution is to stash the interpolated string in a variable outside the iterating block and reference it as necessary.

@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

3 participants