@@ -107,15 +107,11 @@ def get_unchanged_module_references
107
107
#######
108
108
109
109
def remove_from_cache ( module_name )
110
- @module_metadata_cache . each do |cache_key , module_metadata |
111
-
112
- if module_metadata . ref_name . eql? module_name
113
- @module_metadata_cache . delete cache_key
114
- return true
115
- end
116
- end
110
+ removed = @module_metadata_cache . delete_if { |_ , module_metadata |
111
+ module_metadata . ref_name . eql? module_name
112
+ }
117
113
118
- return false
114
+ return ! removed . empty?
119
115
end
120
116
121
117
def wait_for_load
@@ -124,21 +120,14 @@ def wait_for_load
124
120
125
121
def refresh_metadata_instance_internal ( module_instance )
126
122
metadata_obj = Obj . new ( module_instance )
127
- purge_duplicate ( metadata_obj )
128
- @module_metadata_cache [ get_cache_key ( module_instance ) ] = metadata_obj
129
- end
130
123
131
- #
132
- # Remove all instances of modules pointing to the same path. This prevents stale data hanging
133
- # around when modules are incorrectly typed (eg: Auxilary that should be Exploit)
134
- #
135
- def purge_duplicate ( metadata_obj )
136
- @module_metadata_cache . each do |cache_key , module_metadata |
124
+ # Remove all instances of modules pointing to the same path. This prevents stale data hanging
125
+ # around when modules are incorrectly typed (eg: Auxilary that should be Exploit)
126
+ @module_metadata_cache . delete_if { |_ , module_metadata |
127
+ module_metadata . path . eql? metadata_obj . path
128
+ }
137
129
138
- if module_metadata . path . eql? metadata_obj . path
139
- @module_metadata_cache . delete cache_key
140
- end
141
- end
130
+ @module_metadata_cache [ get_cache_key ( module_instance ) ] = metadata_obj
142
131
end
143
132
144
133
def get_cache_key ( module_instance )
0 commit comments