From 40081eb47caca09ad8ae320f85c0b0bfa8b9838f Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 31 May 2022 22:09:33 -0700 Subject: Avoid unnecessary string allocation in Rack::MockRequest.env_for If :input is already provided, this string allocation is unnecessary. --- lib/rack/mock.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/rack/mock.rb b/lib/rack/mock.rb index e6fb57b1..c06e5390 100644 --- a/lib/rack/mock.rb +++ b/lib/rack/mock.rb @@ -149,8 +149,7 @@ module Rack end end - empty_str = String.new - opts[:input] ||= empty_str + opts[:input] ||= String.new if String === opts[:input] rack_input = StringIO.new(opts[:input]) else -- cgit v1.2.3-24-ge0c7