Skip to content

Commit

Permalink
Merge pull request rack#1045 from shhavel/feature/use_string_interpol…
Browse files Browse the repository at this point in the history
…ation_instead_plus

Use String interpolation or << instead plus which are faster
  • Loading branch information
spastorino committed Apr 12, 2016
2 parents 2da7bd3 + 20214d7 commit 9f7703e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/rack/auth/digest/params.rb
Expand Up @@ -38,7 +38,7 @@ def []=(k, v)

def to_s
map do |k, v|
"#{k}=" + (UNQUOTED.include?(k) ? v.to_s : quote(v))
"#{k}=" << (UNQUOTED.include?(k) ? v.to_s : quote(v))
end.join(', ')
end

Expand All @@ -50,4 +50,3 @@ def quote(str) # From WEBrick::HTTPUtils
end
end
end

2 changes: 1 addition & 1 deletion lib/rack/common_logger.rb
Expand Up @@ -48,7 +48,7 @@ def log(env, status, header, began_at)
now.strftime("%d/%b/%Y:%H:%M:%S %z"),
env[REQUEST_METHOD],
env[PATH_INFO],
env[QUERY_STRING].empty? ? "" : "?"+env[QUERY_STRING],
env[QUERY_STRING].empty? ? "" : "?#{env[QUERY_STRING]}",
env[HTTP_VERSION],
status.to_s[0..3],
length,
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/directory.rb
Expand Up @@ -155,7 +155,7 @@ def filesize_format(int)
return format % (int.to_f / size) if int >= size
end

int.to_s + 'B'
"#{int}B"
end
end
end
2 changes: 1 addition & 1 deletion lib/rack/multipart/generator.rb
Expand Up @@ -22,7 +22,7 @@ def dump
else
content_for_other(file, name)
end
end.join + "--#{MULTIPART_BOUNDARY}--\r"
end.join << "--#{MULTIPART_BOUNDARY}--\r"
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/multipart/parser.rb
Expand Up @@ -26,7 +26,7 @@ def read(size)
str = if left < size
@io.read left
else
@io.read size
@io.read size
end

if str
Expand Down

0 comments on commit 9f7703e

Please sign in to comment.