Cache name matching regex

This commit is contained in:
Alfred Xing 2014-11-11 17:35:09 -08:00
parent eaa132c65b
commit d4c15efff9
1 changed files with 3 additions and 1 deletions

View File

@ -9,10 +9,12 @@ module Jekyll
@name = name @name = name
all, @path, @date, @slug = *name.sub(/^\//, "").match(MATCHER) all, @path, @date, @slug = *name.sub(/^\//, "").match(MATCHER)
raise ArgumentError.new("'#{name}' does not contain valid date and/or title.") unless all raise ArgumentError.new("'#{name}' does not contain valid date and/or title.") unless all
@name_regex = /^#{path}#{date}-#{slug}\.[^.]+/
end end
def ==(other) def ==(other)
other.name.match(/^#{path}#{date}-#{slug}\.[^.]+/) other.name.match(@name_regex)
end end
def deprecated_equality(other) def deprecated_equality(other)