aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2012-07-27 02:50:29 -0500
committerJack Nagel2012-07-27 02:50:29 -0500
commite8db4125244445993ebc4aad8126b14bfdc84aae (patch)
tree4330eb0086ac48017ec4db39fa22b02f6c13a17f /Library
parent5e3777a3c8b85f63502c1ccf8adca62c6c682588 (diff)
downloadhomebrew-e8db4125244445993ebc4aad8126b14bfdc84aae.tar.bz2
Deduplicate requirements
Because of some quirks in how formulae are loaded, DSL methods invoked in the class definition are called multiple times. This results in, for example, duplicate dependencies and requirements. Code that iterates over requirements and takes some action for each can thus repeat things that shouldn't be repeated, like appending to environment variables. Make DependencyCollector's external_deps a Set, and define eql? and hash on Requirement to prevent these duplicates. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/dependencies.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb
index 6a4c3e228..43596ad6c 100644
--- a/Library/Homebrew/dependencies.rb
+++ b/Library/Homebrew/dependencies.rb
@@ -1,3 +1,5 @@
+require 'set'
+
## This file defines dependencies and requirements.
##
## A dependency is a formula that another formula needs to install.
@@ -21,7 +23,7 @@ class DependencyCollector
def initialize
@deps = Dependencies.new
- @external_deps = []
+ @external_deps = Set.new
end
def add spec
@@ -119,6 +121,14 @@ class Requirement
def fatal?; false; end
def message; ""; end
def modify_build_environment; nil end
+
+ def eql?(other)
+ other.is_a? self.class and hash == other.hash
+ end
+
+ def hash
+ @message.hash
+ end
end