aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dependency.rb
diff options
context:
space:
mode:
authorJack Nagel2013-05-06 16:08:50 -0500
committerJack Nagel2013-05-06 16:08:50 -0500
commitb32202033881d93849f4c44a837389e8a9d450ef (patch)
tree70c0aada3617c66ddce596ccd20ba3df79fc887e /Library/Homebrew/dependency.rb
parent894a6c9776e33a1ece665e2f8118cd17012878fd (diff)
downloadbrew-b32202033881d93849f4c44a837389e8a9d450ef.tar.bz2
Reduce allocations in dependency construction
By always passing around a single, unnested array rather than splatting and then defensively flattening and compacting things, we can avoid allocating a bunch of unnecessary arrays. This gives a performance boost of roughly 4% when enumerating 2500 formulae, and has the side effect of cleaning up the dependency API.
Diffstat (limited to 'Library/Homebrew/dependency.rb')
-rw-r--r--Library/Homebrew/dependency.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb
index 34320a31b..6c78e10ac 100644
--- a/Library/Homebrew/dependency.rb
+++ b/Library/Homebrew/dependency.rb
@@ -6,9 +6,9 @@ class Dependency
attr_reader :name, :tags
- def initialize(name, *tags)
+ def initialize(name, tags=[])
@name = name
- @tags = tags.flatten.compact
+ @tags = tags
end
def to_s