From 21fa47f92b36d7ed24151d716f713a6b7bc64258 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 25 Feb 2015 11:57:35 -0800 Subject: [PATCH 1/4] Add benchmark-ips to Gemfile. --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index d695524b..d5c970c0 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ gem 'toml', '~> 0.1.0' gem 'jekyll-paginate', '~> 1.0' gem 'jekyll-gist', '~> 1.0' gem 'jekyll-coffeescript', '~> 1.0' +gem 'jekyll-textile-converter', '~> 0.1.0' gem 'classifier-reborn', '~> 2.0' gem 'rake', '~> 10.1' @@ -32,6 +33,7 @@ gem 'test-unit' if RUBY_PLATFORM =~ /cygwin/ || RUBY_VERSION.start_with?("2.2") if ENV['BENCHMARK'] gem 'rbtrace' gem 'stackprof' + gem 'benchmark-ips' end if ENV['PROOF'] From 4da6bfd81ae1369eb2d1222293a266ab3c3f9369 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 25 Feb 2015 11:57:49 -0800 Subject: [PATCH 2/4] Add benchmark for end_with? vs regexp --- benchmark/end-with-vs-regexp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 benchmark/end-with-vs-regexp diff --git a/benchmark/end-with-vs-regexp b/benchmark/end-with-vs-regexp new file mode 100644 index 00000000..cb849f42 --- /dev/null +++ b/benchmark/end-with-vs-regexp @@ -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 From 3f3b20399277624b169cc2d1c7e42d015d5cf76e Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 25 Feb 2015 11:59:27 -0800 Subject: [PATCH 3/4] Use end_with? instead of regexp for adding index.html --- lib/jekyll/document.rb | 2 +- lib/jekyll/page.rb | 2 +- lib/jekyll/post.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 048dcdbf..e22e8cf1 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -163,7 +163,7 @@ module Jekyll def destination(base_directory) dest = site.in_dest_dir(base_directory) path = site.in_dest_dir(dest, URL.unescape_path(url)) - path = File.join(path, "index.html") if url =~ /\/$/ + path = File.join(path, "index.html") if url.end_with?("/") path end diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 98f730bf..2db39141 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -141,7 +141,7 @@ module Jekyll # Returns the destination file path String. def destination(dest) path = site.in_dest_dir(dest, URL.unescape_path(url)) - path = File.join(path, "index.html") if url =~ /\/$/ + path = File.join(path, "index.html") if url.end_with?("/") path end diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index c74522a9..45b6d0d2 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -279,7 +279,7 @@ module Jekyll def destination(dest) # The url needs to be unescaped in order to preserve the correct filename path = site.in_dest_dir(dest, URL.unescape_path(url)) - path = File.join(path, "index.html") if self.url =~ /\/$/ + path = File.join(path, "index.html") if self.url.end_with?("/") path end From 6c073ec476b667202b528158a175f84c218340d7 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 28 Feb 2015 17:29:39 -0800 Subject: [PATCH 4/4] Remove reference to jekyll-textile-converter. --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index d5c970c0..2b39c8f0 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,6 @@ gem 'toml', '~> 0.1.0' gem 'jekyll-paginate', '~> 1.0' gem 'jekyll-gist', '~> 1.0' gem 'jekyll-coffeescript', '~> 1.0' -gem 'jekyll-textile-converter', '~> 0.1.0' gem 'classifier-reborn', '~> 2.0' gem 'rake', '~> 10.1'