From 0bbb14981dc98c647ee9e82b1e969efd0a3e793e Mon Sep 17 00:00:00 2001 From: Sven Riedel Date: Sun, 16 Jun 2019 09:43:46 +0200 Subject: [PATCH] Memoize the result of the module lookup --- lib/rdoc/code_object/mixin.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/code_object/mixin.rb b/lib/rdoc/code_object/mixin.rb index fa8faefc15..2e69987a39 100644 --- a/lib/rdoc/code_object/mixin.rb +++ b/lib/rdoc/code_object/mixin.rb @@ -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. @@ -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