Skip to content

Commit 5fbc750

Browse files
committed
Get rid of mattr_accessor in ActiveSupport::Dependencies
Since the module isn't included anywhere and is purely static there iss no point using `mattr_accessor`, which define instance accessors and other extra overhead. Regular `attr_accessor` does the job just fine.
1 parent 1d6355f commit 5fbc750

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

activesupport/lib/active_support/dependencies.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# frozen_string_literal: true
22

33
require "set"
4-
require "active_support/core_ext/module/attribute_accessors"
54
require "active_support/dependencies/interlock"
65

76
module ActiveSupport # :nodoc:
87
module Dependencies # :nodoc:
98
require_relative "dependencies/require_dependency"
109

11-
mattr_accessor :interlock, default: Interlock.new
10+
singleton_class.attr_accessor :interlock
11+
@interlock = Interlock.new
1212

1313
# :doc:
1414

@@ -40,29 +40,33 @@ def self.unload_interlock
4040
#
4141
# This collection is allowed to have intersection with autoload_once_paths.
4242
# Common directories are not reloaded.
43-
mattr_accessor :autoload_paths, default: []
43+
singleton_class.attr_accessor :autoload_paths
44+
self.autoload_paths = []
4445

4546
# The array of directories from which we autoload and never reload, even if
4647
# reloading is enabled. The public interface to push directories to this
4748
# collection from applications or engines is config.autoload_once_paths.
48-
mattr_accessor :autoload_once_paths, default: []
49+
singleton_class.attr_accessor :autoload_once_paths
50+
self.autoload_once_paths = []
4951

5052
# This is a private set that collects all eager load paths during bootstrap.
5153
# Useful for Zeitwerk integration. The public interface to push custom
5254
# directories to this collection from applications or engines is
5355
# config.eager_load_paths.
54-
mattr_accessor :_eager_load_paths, default: Set.new
56+
singleton_class.attr_accessor :_eager_load_paths
57+
self._eager_load_paths = Set.new
5558

5659
# If reloading is enabled, this private set holds autoloaded classes tracked
5760
# by the descendants tracker. It is populated by an on_load callback in the
5861
# main autoloader. Used to clear state.
59-
mattr_accessor :_autoloaded_tracked_classes, default: Set.new
62+
singleton_class.attr_accessor :_autoloaded_tracked_classes
63+
self._autoloaded_tracked_classes = Set.new
6064

6165
# If reloading is enabled, this private attribute stores the main autoloader
6266
# of a Rails application. It is `nil` otherwise.
6367
#
6468
# The public interface for this autoloader is `Rails.autoloaders.main`.
65-
mattr_accessor :autoloader
69+
singleton_class.attr_accessor :autoloader
6670

6771
# Private method that reloads constants autoloaded by the main autoloader.
6872
#

0 commit comments

Comments
 (0)