Avoid instance_exec for controller callbacks by jhawthorn · Pull Request #43335...
source link: https://github.com/rails/rails/pull/43335
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.
When a proc is passed to a callback (either as a condition or as the callback itself) it is evaluated using instance_exec on the controller instance. Calling instance_exec creates a new singleton class for the object, which then will require new inline method caches.
This commit avoids creating the extra controller singleton classes when :only
or :except
are passed to a callback.
I made an exaggerated benchmark showing the effect: https://gist.github.com/jhawthorn/bded5bc1d5f1afd4cdd7fb5b800312e1
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK