Skip to content

Commit

Permalink
Rack::JSONP. Remove excessive to_ary method call and refactor a little
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin committed May 4, 2020
1 parent 8271d80 commit 537b7cd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/contrib/jsonp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def call(env)

# Set new Content-Length, if it was set before we mutated the response body
if headers['Content-Length']
length = response.to_ary.inject(0) { |len, part| len + part.bytesize }
length = response.map(&:bytesize).reduce(0, :+)
headers['Content-Length'] = length.to_s
end
end
Expand Down

0 comments on commit 537b7cd

Please sign in to comment.