Get rid of `cattr_accessor` in `ActiveRecord::Base` by casperisfine · Pull Reque...
source link: https://github.com/rails/rails/pull/42451
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
See #42442 for full context.
In short class variables are slow, particularly in classes with many ancestors, and ActiveRecord::Base
has over 60 ancestors.
Only a small handful of these really matter performance wise, however the idea is to migrate them all regardless for consistency and to ensure future contributors will follow the new pattern rather than add new mattr/cattr
.
This should be the last ones in ActiveRecord::Base
. There are others in other Active Record classes, but since they don't have large ancestor chains, it doesn't matter much.
I'll look at other classes with large ancestors chains instead (ActionController::Base
?)
Recommend
-
41
A bunch of utilities that enable accessor-based reactivity for JavaScript objects. It can be installed via NPM: npm i d...
-
32
We face a few problems in our PHP projects Illogical type casting (PHP's native implementation is way too "smart") Pointless casts like array => float are allowed...
-
5
How to use Algolia without coupling to ActiveRecord::Base In my video course, I present using Algolia with Rails using the more direct integration provided by algoliasear...
-
10
Copy link Contributor casperisfine c...
-
9
Copy link Contributor casperisfine ...
-
4
Copy link Member seejohnrun ...
-
6
Don't use accessor methods in init and dealloc Aug 14, 2012 苹果在 WWDC 2012 Session 413 - Migrating to Modern Objective-C 里强调不要在 init 和 dealloc 里使用 accessor methods:
-
6
rails_7 Published on 15 September 2022...
-
7
Contributor What does this PR...
-
3
Spatial computing — Everything we learned today about Vision Pro configurations, specs, and accessories It'll cost you $200 to double the storage of the base configuration....
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK