Closed casperisfine closed 3 years ago
@radar any chance this PR could be considered?
Thank you @casperisfine, this looks great.
There is still some issue because i18n/core/hash still gets called in: lib/i18n/backend/chain.rb and lib/i18n/backend/gettext.rb and rails fails to load: `require': cannot load such file -- i18n/core_ext/hash (LoadError)
while Utils is correclty referenced in those files...
Refinements have a very significant performance overhead. The simple fact of refining a method, even if the refinement is never used will make calls to that method 40% slower.
On rarely called methods in doesn't matter that much, but I18n refine some popular Active Support methods, so any project including the I18n gem suffer from a significant performance penalty.
See this benchmark for more details: https://gist.github.com/casperisfine/1c46f05cccfa945cd156f445f0d3d6fa
In the end these refinements are easily replace by simple module functions taking one extra argument.