Convert to boolean in C code
casecmp?(str) is 1.5x faster than casecmp(str).zero? It's 1 less method call in Ruby, and the C code can convert to boolean, rather than returning a number and determining if it's zero.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user