aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2019-04-09 16:31:31 -0400
committerGitHub <noreply@github.com>2019-04-09 16:31:31 -0400
commit8976507439f37bff7300fcc09de45f2f299339b7 (patch)
tree821196531c6eafcf5b91a17ff64497ee96ee9bd8 /activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb
parent21ce5cf6f112b5eee5f125089351427ff8f91a54 (diff)
parent6f26e99cef4b6f20be8ef5cf7fee4b4755baaaec (diff)
downloadrails-8976507439f37bff7300fcc09de45f2f299339b7.tar.gz
rails-8976507439f37bff7300fcc09de45f2f299339b7.tar.bz2
rails-8976507439f37bff7300fcc09de45f2f299339b7.zip
Merge pull request #35875 from Shopify/alloc-free-comparisons
Improve == and hash methods on various schema cache structs to be allocation free.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb b/activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb
index cd69d28139..403b3ead98 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb
@@ -22,19 +22,20 @@ module ActiveRecord
def ==(other)
other.is_a?(PostgreSQLTypeMetadata) &&
- attributes_for_hash == other.attributes_for_hash
+ __getobj__ == other.__getobj__ &&
+ oid == other.oid &&
+ fmod == other.fmod &&
+ array == other.array
end
alias eql? ==
def hash
- attributes_for_hash.hash
+ PostgreSQLTypeMetadata.hash ^
+ __getobj__.hash ^
+ oid.hash ^
+ fmod.hash ^
+ array.hash
end
-
- protected
-
- def attributes_for_hash
- [self.class, @type_metadata, oid, fmod]
- end
end
end
end