From d4c15efff9fc1138e429652771787066268cd248 Mon Sep 17 00:00:00 2001 From: Alfred Xing Date: Tue, 11 Nov 2014 17:35:09 -0800 Subject: [PATCH] Cache name matching regex --- lib/jekyll/tags/post_url.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index 1ffff635..ce97642f 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -9,10 +9,12 @@ module Jekyll @name = name all, @path, @date, @slug = *name.sub(/^\//, "").match(MATCHER) raise ArgumentError.new("'#{name}' does not contain valid date and/or title.") unless all + + @name_regex = /^#{path}#{date}-#{slug}\.[^.]+/ end def ==(other) - other.name.match(/^#{path}#{date}-#{slug}\.[^.]+/) + other.name.match(@name_regex) end def deprecated_equality(other)