-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compute relative_path of pages using PathManager #8408
Conversation
Benchmark reportResults from Ruby 2.4 on Windows
The proposed change is only slow for edge-cases. However, there is significant improvement for pages in subdirectories. |
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.
Looks good now.
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.
Nice! One question.
page = PageWithoutAFile.new(@site, @site.source, dir, name) | ||
assert_equal result, page.path | ||
assert_equal result, page.relative_path | ||
refute page.relative_path.frozen? |
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.
Is the relative path modified? Why is it important that it's unfrozen?
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.
For backwards-compatibility. It is an unfrozen string in v4.1.
Jekyll::PathManager.join
returns a frozen cached string. So this test confirms that page.relative_path
hasn't changed behavior in v4.2..
Thank you the reviews @DirtyF and @parkr |
Summary
File.join
is sensitive tonil
arguments. So we need to coerce arguments to String to be safer.Using
Jekyll::PathManager.join
on the other hand allows optimized execution for same results.Context
Prior discussions: #8404 (comment)