diff options
| author | Jack Nagel | 2013-04-16 03:31:29 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-04-16 09:53:02 -0500 |
| commit | 475a489f64a9cf4b7c0e47421cc1ff289b2245c7 (patch) | |
| tree | bb83d450681902505f10f511731798c7a0625094 /Library | |
| parent | b596f73c03cb8976ad774f3a14c2a20dcc426dac (diff) | |
| download | homebrew-475a489f64a9cf4b7c0e47421cc1ff289b2245c7.tar.bz2 | |
Reduce repeated array inclusion check
Currently we check if "tag" is present in LANGUAGE_MODULES for every
String dep, even if tag is nil. Stop doing this, and make the
LANGUAGE_MODULES array into a Set instead to improve lookup performance.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/dependency_collector.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 0c423cd09..22f690a8c 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -2,6 +2,7 @@ require 'dependency' require 'dependencies' require 'requirement' require 'requirements' +require 'set' ## A dependency is a formula that another formula needs to install. ## A requirement is something other than a formula that another formula @@ -15,7 +16,7 @@ require 'requirements' # specifications into the proper kinds of dependencies and requirements. class DependencyCollector # Define the languages that we can handle as external dependencies. - LANGUAGE_MODULES = [ + LANGUAGE_MODULES = Set[ :chicken, :jruby, :lua, :node, :ocaml, :perl, :python, :rbx, :ruby ].freeze @@ -52,7 +53,7 @@ class DependencyCollector when Symbol parse_symbol_spec(spec, tag) when String - if LANGUAGE_MODULES.include? tag + if tag && LANGUAGE_MODULES.include?(tag) LanguageModuleDependency.new(tag, spec) else Dependency.new(spec, tag) |
