Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

avoid copying entire payload just to calc md5

  • Loading branch information...
commit 16a0033784a459563140e4f3df2c4973f105bbf9 1 parent 0adc7ce
Sam authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/rack/etag.rb
12 lib/rack/etag.rb
View
@@ -55,10 +55,14 @@ def skip_caching?(headers)
def digest_body(body)
parts = []
- body.each { |part| parts << part }
- string_body = parts.join
- digest = Digest::MD5.hexdigest(string_body) unless string_body.empty?
- [digest, parts]
+ digest = nil
+
+ body.each do |part|
+ parts << part
+ (digest ||= Digest::MD5.new) << part unless part.empty?
Sam Owner

should this be part && part.empty? since [nil].join == ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ end
+
+ [digest && digest.hexdigest, parts]
end
end
end
Sam

should this be part && part.empty? since [nil].join == ""

Please sign in to comment.
Something went wrong with that request. Please try again.