mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:11:08 +08:00
PERF: optimize homepage and topic performance (#11607)
These are a few small tweaks that slightly improve performance. - we omitted 1 query from the post guardian which could cause an N+1 - cook_url has been sped up a bit - url helper avoids re-creating sets for no reason
This commit is contained in:
@ -14,15 +14,15 @@ class FileHelper
|
||||
end
|
||||
|
||||
def self.is_supported_image?(filename)
|
||||
(filename =~ supported_images_regexp).present?
|
||||
filename.match?(supported_images_regexp)
|
||||
end
|
||||
|
||||
def self.is_inline_image?(filename)
|
||||
(filename =~ inline_images_regexp).present?
|
||||
filename.match?(inline_images_regexp)
|
||||
end
|
||||
|
||||
def self.is_supported_media?(filename)
|
||||
(filename =~ supported_media_regexp).present?
|
||||
filename.match?(supported_media_regexp)
|
||||
end
|
||||
|
||||
class FakeIO
|
||||
@ -162,7 +162,10 @@ class FileHelper
|
||||
end
|
||||
|
||||
def self.supported_media_regexp
|
||||
media = supported_images | supported_audio | supported_video
|
||||
@@supported_media_regexp ||= /\.(#{media.to_a.join("|")})$/i
|
||||
@@supported_media_regexp ||=
|
||||
begin
|
||||
media = supported_images | supported_audio | supported_video
|
||||
/\.(#{media.to_a.join("|")})$/i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user