Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3516 from jekyll/end-with
Use String#end_with?("/") instead of regexp
- Loading branch information
Showing
5 changed files
with
17 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'benchmark/ips' | ||
|
||
Benchmark.ips do |x| | ||
path_without_ending_slash = '/some/very/very/long/path/to/a/file/i/like' | ||
x.report('no slash regexp') { path_without_ending_slash =~ /\/$/ } | ||
x.report('no slash end_with?') { path_without_ending_slash.end_with?("/") } | ||
end | ||
|
||
Benchmark.ips do |x| | ||
path_with_ending_slash = '/some/very/very/long/path/to/a/file/i/like/' | ||
x.report('slash regexp') { path_with_ending_slash =~ /\/$/ } | ||
x.report('slash end_with?') { path_with_ending_slash.end_with?("/") } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters