Skip to content

Commit

Permalink
Just track "require" if we have something in the watching stack.
Browse files Browse the repository at this point in the history
A patch has been provided earlier and we have asked for feedback:

    https://gist.github.com/1437939

Except one case, all other cases showed improvements in boot time.
  • Loading branch information
josevalim committed Dec 6, 2011
1 parent 9dee540 commit 885a599
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion activesupport/lib/active_support/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def each(&block)
@stack.each(&block)
end

def watching?
!@watching.empty?
end

# return a list of new constants found since the last call to watch_namespaces
def new_constants
constants = []
Expand Down Expand Up @@ -226,7 +230,7 @@ def require_association(file_name)
end

def load_dependency(file)
if Dependencies.load?
if Dependencies.load? && ActiveSupport::Dependencies.constant_watch_stack.watching?
Dependencies.new_constants_in(Object) { yield }
else
yield
Expand Down

3 comments on commit 885a599

@arunagw
Copy link
Member

@arunagw arunagw commented on 885a599 Dec 7, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@ugisozols
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asanghi
Copy link
Contributor

@asanghi asanghi commented on 885a599 Dec 7, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backport to 3.0 branch please!!

Please sign in to comment.