Skip to content

Commit

Permalink
Merge pull request #17355 from NickLaMuro/memoize_log_prefix_calls_in…
Browse files Browse the repository at this point in the history
…_miq_request_workflow

Memoize _log.prefix calls
(cherry picked from commit c2e01c9)

https://bugzilla.redhat.com/show_bug.cgi?id=1593798
  • Loading branch information
bdunne authored and simaishi committed Jun 21, 2018
1 parent 553db93 commit ef6b3f9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/models/miq_request_workflow.rb
Expand Up @@ -822,7 +822,8 @@ def find_respools_under_ci(item)
def find_classes_under_ci(item, klass)
results = []
return results if item.nil?
node = load_ems_node(item, _log.prefix)
@_find_classes_under_ci_prefix ||= _log.prefix
node = load_ems_node(item, @_find_classes_under_ci_prefix)
each_ems_metadata(node.attributes[:object], klass) { |ci| results << ci } unless node.nil?
results
end
Expand Down Expand Up @@ -852,7 +853,8 @@ def get_ems_folders(folder, dh = {}, full_path = "")
end

# Process child folders
node = load_ems_node(folder, _log.prefix)
@_get_ems_folders_prefix ||= _log.prefix
node = load_ems_node(folder, @_get_ems_folders_prefix)
node.children.each { |child| get_ems_folders(child.attributes[:object], dh, full_path) } unless node.nil?

dh
Expand Down Expand Up @@ -892,7 +894,8 @@ def find_cluster_above_ci(item, ems_src = nil)

def find_class_above_ci(item, klass, _ems_src = nil, datacenter = false)
result = nil
node = load_ems_node(item, _log.prefix)
@_find_class_above_ci_prefix ||= _log.prefix
node = load_ems_node(item, @_find_class_above_ci_prefix)
klass_name = klass.name.to_sym
# Walk the xml document parents to find the requested class
while node.kind_of?(XmlHash::Element)
Expand All @@ -913,7 +916,8 @@ def each_ems_metadata(ems_ci = nil, klass = nil, &_blk)
ems_xml = get_ems_metadata_tree(src)
ems_node = ems_xml.try(:root)
else
ems_node = load_ems_node(ems_ci, _log.prefix)
@_each_ems_metadata_prefix ||= _log.prefix
ems_node = load_ems_node(ems_ci, @_each_ems_metadata_prefix)
end
klass_name = klass.name.to_sym unless klass.nil?
unless ems_node.nil?
Expand Down Expand Up @@ -1017,7 +1021,8 @@ def allowed_hosts_obj(options = {})
hosts_ids = find_all_ems_of_type(Host).collect(&:id)
hosts_ids &= load_ar_obj(src[:storage]).hosts.collect(&:id) unless src[:storage].nil?
if datacenter
dc_node = load_ems_node(datacenter, _log.prefix)
@_allowed_hosts_obj_prefix ||= _log.prefix
dc_node = load_ems_node(datacenter, @_allowed_hosts_obj_prefix)
hosts_ids &= find_hosts_under_ci(dc_node.attributes[:object]).collect(&:id)
end
return [] if hosts_ids.blank?
Expand Down

0 comments on commit ef6b3f9

Please sign in to comment.