From 9f5835871b2e3b23b6d5f78caa445790901be012 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 12 Oct 2014 16:17:23 -0700 Subject: [PATCH] Utils.slugify: Don't create new objects when gsubbing --- lib/jekyll/utils.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index d528f22d..b54e4f45 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -111,11 +111,13 @@ module Jekyll # hyphen. def slugify(string) unless string.nil? - # Replace each non-alphanumeric character sequence with a hyphen - slug = string.gsub(/[^a-z0-9]+/i, '-') - # Remove leading/trailing hyphen - slug.gsub!(/^\-|\-$/i, '') - slug.downcase + string \ + # Replace each non-alphanumeric character sequence with a hyphen + .gsub(/[^a-z0-9]+/i, '-') \ + # Remove leading/trailing hyphen + .gsub(/^\-|\-$/i, '') \ + # Downcase it + .downcase end end