Skip to content

Instantly share code, notes, and snippets.

@cheald
Created June 17, 2015 23:07
Show Gist options
  • Save cheald/ae868290a23f6b1048c5 to your computer and use it in GitHub Desktop.
Save cheald/ae868290a23f6b1048c5 to your computer and use it in GitHub Desktop.
# Before
bin/jruby --dev -e "require 'active_support/all'; p ActiveSupport" 10.51s user 0.35s system 185% cpu 5.855 total
bin/jruby --dev -e "require 'active_support/all'; p ActiveSupport" 9.64s user 0.35s system 182% cpu 5.468 total
bin/jruby --dev -e "require 'active_support/all'; p ActiveSupport" 10.07s user 0.40s system 181% cpu 5.781 total
# After
bin/jruby --dev -e "require 'active_support/all'; p ActiveSupport" 8.70s user 0.31s system 185% cpu 4.852 total
bin/jruby --dev -e "require 'active_support/all'; p ActiveSupport" 9.50s user 0.37s system 186% cpu 5.280 total
bin/jruby --dev -e "require 'active_support/all'; p ActiveSupport" 8.66s user 0.32s system 185% cpu 4.830 total
diff --git a/lib/ruby/stdlib/rubygems/specification.rb b/lib/ruby/stdlib/rubygems/specification.rb
index eb89c4c..3206825 100644
--- a/lib/ruby/stdlib/rubygems/specification.rb
+++ b/lib/ruby/stdlib/rubygems/specification.rb
@@ -944,7 +944,7 @@ class Gem::Specification < Gem::BasicSpecification
def self.find_in_unresolved path
# TODO: do we need these?? Kill it
- specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
+ specs = unresolved_deps.values.flat_map { |dep| dep.to_specs }
specs.find_all { |spec| spec.contains_requirable_file? path }
end
@@ -954,7 +954,7 @@ class Gem::Specification < Gem::BasicSpecification
# specs that contain the file matching +path+.
def self.find_in_unresolved_tree path
- specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
+ specs = unresolved_deps.values.flat_map { |dep| dep.to_specs }
specs.reverse_each do |spec|
trails = []
@@ -1014,7 +1014,7 @@ class Gem::Specification < Gem::BasicSpecification
result[spec.name][spec.platform] = spec
end
- result.map(&:last).map(&:values).flatten.reject { |spec|
+ result.map(&:last).flat_map(&:values).reject { |spec|
minimum = native[spec.name]
minimum && spec.version < minimum
}.sort_by{ |tup| tup.name }
@@ -1625,7 +1625,7 @@ class Gem::Specification < Gem::BasicSpecification
# Returns all specs that matches this spec's runtime dependencies.
def dependent_specs
- runtime_dependencies.map { |dep| dep.to_specs }.flatten
+ runtime_dependencies.flat_map { |dep| dep.to_specs }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment