Commit 3d355cec authored by Robert Speicher's avatar Robert Speicher

Merge branch '217580-improve-blob-show-performance' into 'master'

Improve BlobController show.json performance: cache method calls

See merge request gitlab-org/gitlab!33876
parents 01263b0c 56f3dcd9
...@@ -675,10 +675,11 @@ class Project < ApplicationRecord ...@@ -675,10 +675,11 @@ class Project < ApplicationRecord
# '>' or its escaped form ('&gt;') are checked for because '>' is sometimes escaped # '>' or its escaped form ('&gt;') are checked for because '>' is sometimes escaped
# when the reference comes from an external source. # when the reference comes from an external source.
def markdown_reference_pattern def markdown_reference_pattern
%r{ @markdown_reference_pattern ||=
#{reference_pattern} %r{
(#{reference_postfix}|#{reference_postfix_escaped}) #{reference_pattern}
}x (#{reference_postfix}|#{reference_postfix_escaped})
}x
end end
def trending def trending
......
...@@ -619,11 +619,12 @@ class User < ApplicationRecord ...@@ -619,11 +619,12 @@ class User < ApplicationRecord
# Pattern used to extract `@user` user references from text # Pattern used to extract `@user` user references from text
def reference_pattern def reference_pattern
%r{ @reference_pattern ||=
(?<!\w) %r{
#{Regexp.escape(reference_prefix)} (?<!\w)
(?<user>#{Gitlab::PathRegex::FULL_NAMESPACE_FORMAT_REGEX}) #{Regexp.escape(reference_prefix)}
}x (?<user>#{Gitlab::PathRegex::FULL_NAMESPACE_FORMAT_REGEX})
}x
end end
# Return (create if necessary) the ghost user. The ghost user # Return (create if necessary) the ghost user. The ghost user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment