You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All the complexity of that method was to work around various
problems caused by Ruby's constant lookup semantic as well
as the classic autoloader shortcommings.
Now that Rails require Ruby 2.7 I don't think we need anything
more than just `Object.const_get`.
```ruby
require 'benchmark/ips'
require 'active_support/all'
module Foo
module Bar
module Baz
end
end
end
def patched_constantize(name)
Object.const_get(name)
end
Benchmark.ips do |x|
x.report('orig') { ActiveSupport::Inflector.constantize("Foo::Bar::Baz") }
x.report('patched') { patched_constantize("Foo::Bar::Baz") }
x.compare!
end
```
```
Warming up --------------------------------------
orig 69.668k i/100ms
patched 391.385k i/100ms
Calculating -------------------------------------
orig 705.027k (± 1.9%) i/s - 3.553M in 5.041486s
patched 3.935M (± 1.1%) i/s - 19.961M in 5.072912s
Comparison:
patched: 3935235.5 i/s
orig: 705027.2 i/s - 5.58x (± 0.00) slower
```
0 commit comments