Skip to content
This repository
Browse code

Switch to hash for recording already seen tasks in all_prerequisite_t…

…asks.
  • Loading branch information...
commit a3e9a02ae67cf1e55b29afc63fec2615198c08d5 1 parent b282318
Jim Weirich authored

Showing 1 changed file with 7 additions and 4 deletions. Show diff stats Hide diff stats

  1. +7 4 lib/rake/task.rb
11 lib/rake/task.rb
@@ -65,14 +65,17 @@ def lookup_prerequisite(prerequisite_name)
65 65 # prerequisites.
66 66 # Includes self when cyclic dependencies are found.
67 67 def all_prerequisite_tasks
68   - fetch_prerequisites
  68 + seen = {}
  69 + collect_prerequisites(seen)
  70 + seen.values
69 71 end
70 72
71   - def fetch_prerequisites(list=[])
  73 + def collect_prerequisites(seen)
72 74 prerequisite_tasks.each do |pre|
73   - list << pre and pre.fetch_prerequisites(list) unless list.include?(pre)
  75 + next if seen[pre.name]
  76 + seen[pre.name] = pre
  77 + pre.collect_prerequisites(seen)
74 78 end
75   - list
76 79 end
77 80 protected :fetch_prerequisites
78 81

0 comments on commit a3e9a02

Please sign in to comment.
Something went wrong with that request. Please try again.