Permalink
Browse files

don't sort gems every time you add one

geminabox is basically unusable with large gem collections.
This helps to relieve that by only sorting GemVersionCollection once
upon initialization, instead of every time a gem is added.
  • Loading branch information...
1 parent cd9fdc4 commit a6f3ac9ae950ff0e1bfed8891de0798e8b11e681 Nat Williams committed Oct 25, 2012
Showing with 8 additions and 4 deletions.
  1. +3 −3 lib/geminabox.rb
  2. +5 −1 lib/geminabox/gem_version_collection.rb
View
@@ -123,14 +123,14 @@ def fixup_bundler_rubygems!
error_response(200, "Ignoring upload, you uploaded the same thing previously.")
end
end
-
+
atomic_write(dest_filename) do |f|
while blk = tmpfile.read(65536)
f << blk
end
end
reindex
-
+
if api_request?
"Gem #{gem_name} received and indexed."
else
@@ -211,7 +211,7 @@ def atomic_write(file_name)
temp_file.close
File.rename(temp_file.path, file_name)
end
-
+
helpers do
def spec_for(gem_name, version)
spec_file = File.join(settings.data, "quick", "Marshal.#{Gem.marshal_version}", "#{gem_name}-#{version}.gemspec.rz")
@@ -12,6 +12,7 @@ def size
def initialize(initial_gems=[])
@gems = []
initial_gems.each { |gemdef| self << gemdef }
+ sort!
end
def <<(version_or_def)
@@ -22,7 +23,6 @@ def <<(version_or_def)
end
@gems << version
- @gems.sort!
end
def oldest
@@ -54,6 +54,10 @@ def by_name
end
end
+ def sort!
+ @gems.sort!
+ end
+
private
def hash_of_collections
Hash.new { |h,k| h[k] = self.class.new }

0 comments on commit a6f3ac9

Please sign in to comment.