mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:23:13 +08:00
PERF: Move URI regexp in GroupSearchResults.blurb_for
into constant
No need to generate the huge regexp over and over again.
This commit is contained in:
parent
1f7b44de67
commit
4c03a944f6
|
@ -85,12 +85,14 @@ class Search
|
|||
end
|
||||
end
|
||||
|
||||
URI_REGEXP = URI.regexp(%w{http https})
|
||||
|
||||
def self.blurb_for(cooked: nil, term: nil, blurb_length: BLURB_LENGTH, scrub: true)
|
||||
blurb = nil
|
||||
cooked = SearchIndexer.scrub_html_for_search(cooked) if scrub
|
||||
|
||||
urls = Set.new
|
||||
cooked.scan(URI.regexp(%w{http https})) { urls << $& }
|
||||
cooked.scan(URI_REGEXP) { urls << $& }
|
||||
urls.each do |url|
|
||||
begin
|
||||
case File.extname(URI(url).path || "")
|
||||
|
|
Loading…
Reference in New Issue
Block a user