Skip to content

Commit fa33ba3

Browse files
Merge pull request rails#46830 from skipkayhil/optimize-env-local
Use precompute optimization for Rails.env.local?
2 parents a731e5e + ba2e06a commit fa33ba3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

activesupport/lib/active_support/environment_inquirer.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def initialize(env)
2020
DEFAULT_ENVIRONMENTS.each do |default|
2121
instance_variable_set :"@#{default}", env == default
2222
end
23+
24+
@local = in? LOCAL_ENVIRONMENTS
2325
end
2426

2527
DEFAULT_ENVIRONMENTS.each do |env|
@@ -28,7 +30,7 @@ def initialize(env)
2830

2931
# Returns true if we're in the development or test environment.
3032
def local?
31-
in? LOCAL_ENVIRONMENTS
33+
@local
3234
end
3335
end
3436
end

0 commit comments

Comments
 (0)