Skip to content

Commit 7836a16

Browse files
committed
Avoid late require calls in potential hot spots
Ref: https://bugs.ruby-lang.org/issues/20641 Granted it's an upstream bug, but even without the bug `require` isn't cheap. `ConfigurationFile` isn't that hot of a spot in production, but in Active Record test suite it's called for almost every test so with this Ruby 3.3 bug it account for significant part of the test suite runtime.
1 parent 55c4ade commit 7836a16

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

activesupport/lib/active_support/configuration_file.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def parse(context: nil, **options)
3333

3434
private
3535
def read(content_path)
36-
require "yaml"
37-
require "erb"
36+
require "yaml" unless defined?(YAML)
37+
require "erb" unless defined?(ERB)
3838

3939
File.read(content_path).tap do |content|
4040
if content.include?("\u00A0")

0 commit comments

Comments
 (0)