Merge branch 'performance_boosts' into 'develop'

Performance boosts

See merge request gab/social/gab-social!64
This commit is contained in:
Free Speech Forever
2021-02-18 07:09:28 +00:00
9 changed files with 19 additions and 17 deletions

View File

@@ -53,7 +53,7 @@ module JsonLdHelper
needle = Addressable::URI.parse(url).host
haystack = Addressable::URI.parse(@account.uri).host
!haystack.casecmp(needle).zero?
!haystack.casecmp?(needle)
end
def canonicalize(json)

View File

@@ -370,7 +370,7 @@ class Formatter
escaped = text.chars.map do |c|
output = begin
if c.ord.to_s(16).length > 2 && UNICODE_ESCAPE_BLACKLIST_RE.match(c).nil?
if c.ord > 255 && !UNICODE_ESCAPE_BLACKLIST_RE.match?(c)
CGI.escape(c)
else
c

View File

@@ -7,11 +7,11 @@ class TagManager
include RoutingHelper
def web_domain?(domain)
domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.web_domain).zero?
domain.nil? || domain.gsub(/[\/]/, '').casecmp?(Rails.configuration.x.web_domain)
end
def local_domain?(domain)
domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.local_domain).zero?
domain.nil? || domain.gsub(/[\/]/, '').casecmp?(Rails.configuration.x.local_domain)
end
def normalize_domain(domain)
@@ -35,9 +35,9 @@ class TagManager
end
def same_acct?(canonical, needle)
return true if canonical.casecmp(needle).zero?
return true if canonical.casecmp?(needle)
username, domain = needle.split('@')
local_domain?(domain) && canonical.casecmp(username).zero?
local_domain?(domain) && canonical.casecmp?(username)
end
def local_url?(url)

View File

@@ -8,7 +8,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
attribute :favourited, if: :current_user?
attribute :reblogged, if: :current_user?
attribute :content, unless: :source_requested?
attribute :rich_content, unless: :source_requested?
attribute :plain_markdown, unless: :source_requested?
@@ -110,11 +110,12 @@ class REST::StatusSerializer < ActiveModel::Serializer
return
end
PINNABLE_VISIBILITIES = %w(public unlisted).freeze
def pinnable
current_user? &&
current_user.account_id == object.account_id &&
!object.reblog? &&
%w(public unlisted).include?(object.visibility)
PINNABLE_VISIBILITIES.include?(object.visibility)
end
def pinned_by_group
@@ -122,11 +123,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
end
def pinnable_by_group
if object.group_id?
true
else
false
end
object.group_id?
end
def source_requested?