Commit afdc0285 authored by Yorick Peterse's avatar Yorick Peterse

Speed up searching for text references a bit

If a node is ignored there's no need for searching for a given pattern.
In turn, when searching for the pattern there's no need to construct a
MatchData object as we only care about presence (or lack thereof), not
the resulting matches.

In terms of performance this cuts down about 200 ms when loading
issue #2164 locally, though this varies a bit depending on system load.
parent 97eafd4b
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.2.0 (unreleased) v 8.2.0 (unreleased)
- Improved performance of replacing references in comments
- Fix duplicate repositories in GitHub import page (Stan Hu) - Fix duplicate repositories in GitHub import page (Stan Hu)
- Show last project commit to default branch on project home page - Show last project commit to default branch on project home page
- Highlight comment based on anchor in URL - Highlight comment based on anchor in URL
......
...@@ -107,10 +107,10 @@ module Gitlab ...@@ -107,10 +107,10 @@ module Gitlab
return doc if project.nil? return doc if project.nil?
search_text_nodes(doc).each do |node| search_text_nodes(doc).each do |node|
content = node.to_html
next unless content.match(pattern)
next if ignored_ancestry?(node) next if ignored_ancestry?(node)
next unless node.text =~ pattern
content = node.to_html
html = yield content html = yield content
......
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