Permalink
Browse files

Memoize pattern construction

  • Loading branch information...
1 parent 017c112 commit dd93ef08c59e4bacb46f0c7d671d28db8182afc2 @methodmissing committed Jul 12, 2009
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/fuzz/token.rb
View
@@ -98,6 +98,11 @@ def pattern
Regexp.compile(rx.force_encoding("utf-8"), Regexp::IGNORECASE )
end
+ alias :real_pattern :pattern
+ def pattern
+ @pattern ||= real_pattern()
+ end
+
def match(str)
# perform the initial match by comparing
# the string with this classes regex, and

0 comments on commit dd93ef0

Please sign in to comment.