Eliminate allocations on Model.respond_to? calls by tenderlove

14-Jan-2025 33
We're trying to make instantiating models cheaper (for example doing Post.new), and discovered in the course of profiling that respond_to? is responsible for some amount of initialization allocations. This patch changes Model.respond_to? to not allocate anymore which should help initialization performance (as well as other queries). Here is the benchmark we used:.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle