frozen_string_literalreduces the generated garbage by ~100MB or ~20%! Free performance by adding a one line comment.
Gem authors: add
# frozen_string_literal: trueto the top of all Ruby files in a gem. It gives a free performance improvement to all your users as long as you don’t use String mutation.
Mike Perham: Ruby Optimization with One Magic Comment, 2018-02-28: https://www.mikeperham.com/2018/02/28/ruby-optimization-with-one-magic-comment/
Symbol as hash keys:
If you use Ruby 2.2,
Symbolcould be more performant than
Fast Ruby: https://github.com/fastruby/fast-ruby#hash
Leave an answer