Halve memory allocation in S3Service#download

Aws::S3::Object#get returns a response with object content wrapped in an
in-memory StringIO object. StringIO#read will return a copy of the
content, which is not necessary because we can return the content
directly using StringIO#string. This halves memory allocation of
S3Service#download, because we remove unnecessary content duplication.
上级 80cbf194
......@@ -33,7 +33,7 @@ def download(key, &block)
end
else
instrument :download, key: key do
object_for(key).get.body.read.force_encoding(Encoding::BINARY)
object_for(key).get.body.string.force_encoding(Encoding::BINARY)
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册