cache file extension regexp instead of recompiling it every time
Charlie Somerville charlie@charliesomerville.com
Wed, 04 Dec 2013 11:31:13 +1100
1 files changed,
6 insertions(+),
1 deletions(-)
M
lib/github/markup/implementation.rb
→
lib/github/markup/implementation.rb
@@ -16,7 +16,12 @@ raise NotImplementedError, "subclasses of GitHub::Markup::Implementation must define #render"
end def match?(filename) - Regexp.compile("\\.(#{regexp})$") =~ filename + file_ext_regexp =~ filename + end + + private + def file_ext_regexp + @file_ext_regexp ||= /\.(#{regexp})\z/ end end end