diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-03-24 16:41:48 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-04-01 11:13:30 +0200 |
commit | e7849b0b25390a96881d1f8affd1eadab4e9de62 (patch) | |
tree | 1520ff521f9c885f4987747b167e3be7b8182aad /app/models/commit_range.rb | |
parent | 82539cff700931532b22b6a8e3d6832137fc5d55 (diff) | |
download | gitlab-ce-e7849b0b25390a96881d1f8affd1eadab4e9de62.tar.gz |
Memoize reference_pattern/link_reference_patternmemoize-pattern-methods
These methods are called quite often in loops so by memoizing their
output we can reduce timings a bit.
Diffstat (limited to 'app/models/commit_range.rb')
-rw-r--r-- | app/models/commit_range.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/commit_range.rb b/app/models/commit_range.rb index 289dbc57287..51673897d98 100644 --- a/app/models/commit_range.rb +++ b/app/models/commit_range.rb @@ -43,14 +43,14 @@ class CommitRange # # This pattern supports cross-project references. def self.reference_pattern - %r{ + @reference_pattern ||= %r{ (?:#{Project.reference_pattern}#{reference_prefix})? (?<commit_range>#{STRICT_PATTERN}) }x end def self.link_reference_pattern - super("compare", /(?<commit_range>#{PATTERN})/) + @link_reference_pattern ||= super("compare", /(?<commit_range>#{PATTERN})/) end # Initialize a CommitRange |