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:
@@ -44,13 +44,13 @@ module GabSocial
|
||||
# Stub for Database.postgresql? from GitLab
|
||||
def self.postgresql?
|
||||
%w[postgresql postgresql_makara].any? do |adapter|
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp(adapter).zero?
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp?(adapter)
|
||||
end
|
||||
end
|
||||
|
||||
# Stub for Database.mysql? from GitLab
|
||||
def self.mysql?
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp('mysql2').zero?
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter'].casecmp?('mysql2')
|
||||
end
|
||||
|
||||
# Model that can be used for querying permissions of a SQL user.
|
||||
|
||||
Reference in New Issue
Block a user