heartcombo / responders

A set of Rails responders to dry up your application
http://blog.plataformatec.com.br/
MIT License
2.05k stars 156 forks source link

Deduplicate action names #203

Closed casperisfine closed 5 years ago

casperisfine commented 5 years ago

While running memory_profiler against our app, I noticed responders was duplicating some action names:

Retained String Report
-----------------------------------
    "show"
132  /tmp/bundle/ruby/2.5.0/gems/responders-2.4.1/lib/action_controller/respond_with.rb:40

    "index"
126  /tmp/bundle/ruby/2.5.0/gems/responders-2.4.1/lib/action_controller/respond_with.rb:40

Solution

Rather than to cast all that as strings, we do the inverse, we cast everything as symbols. These are action names, so they're normally a fairly limited set. Interning them shouldn't be a concern.

cc @rafaelfranca

sourcelevel-bot[bot] commented 5 years ago

Hello, @casperisfine! This is your first Pull Request that will be reviewed by Ebert, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information.