summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-10-20 16:26:53 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-10-20 16:26:53 +0000
commit249a9476d44e89bf1ab12fbc40bf81478faafd12 (patch)
tree6e44d47264475a7ec411534758b2efded50253a3 /lib
parentf16bfa401f4f2acc11ff089df8ba0bb092df416a (diff)
parente1c3077e4bb718ce841fad175f708623d8375818 (diff)
downloadgitlab-ce-249a9476d44e89bf1ab12fbc40bf81478faafd12.tar.gz
Merge branch 'reference-filter-replace-text-nodes-performance' into 'master'
Speed up searching for text references a bit See merge request !1648
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/markdown/reference_filter.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/gitlab/markdown/reference_filter.rb b/lib/gitlab/markdown/reference_filter.rb
index adaca78ba27..a4c560f578c 100644
--- a/lib/gitlab/markdown/reference_filter.rb
+++ b/lib/gitlab/markdown/reference_filter.rb
@@ -15,7 +15,7 @@ module Gitlab
LazyReference = Struct.new(:klass, :ids) do
def self.load(refs)
lazy_references, values = refs.partition { |ref| ref.is_a?(self) }
-
+
lazy_values = lazy_references.group_by(&:klass).flat_map do |klass, refs|
ids = refs.flat_map(&:ids)
klass.where(id: ids)
@@ -107,10 +107,10 @@ module Gitlab
return doc if project.nil?
search_text_nodes(doc).each do |node|
- content = node.to_html
-
- next unless content.match(pattern)
next if ignored_ancestry?(node)
+ next unless node.text =~ pattern
+
+ content = node.to_html
html = yield content