Skip to content

Commit

Permalink
Memoize the result of the module lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Riedel committed Jun 16, 2019
1 parent 5f9603f commit d056dc6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/rdoc/mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def inspect # :nodoc:
]
end

def module
return @memoized_module if instance_variable_defined?(:@memoized_module)

@memoized_module = lookup_module
end

##
# Attempts to locate the included module object. Returns the name if not
# known.
Expand All @@ -72,7 +78,7 @@ def inspect # :nodoc:
#
# As of the beginning of October, 2011, no gem includes nonexistent modules.

def module
def lookup_module
return @module if @module

# search the current context
Expand Down

0 comments on commit d056dc6

Please sign in to comment.