Skip to content

Commit

Permalink
Use String.build instead of concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Jun 16, 2024
1 parent 0127fc8 commit 91c2753
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/ext/kemal_gphoto2.cr
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,17 @@ def send_file(env, file : GPhoto2::CameraFile, *, format : ImageOutputFormat?, w
end
end

filename = path.stem
filename += "-w#{width}" if width
filename += "-h#{height}" if height
filename +=
if path.extension.chars.select!(&.letter?).all?(&.uppercase?)
format.extension.upcase
else
format.extension
end

filename = String.build do |str|
str << path.stem
str << "-w#{width}" if width
str << "-h#{height}" if height
str <<
if path.extension.chars.select!(&.letter?).all?(&.uppercase?)
format.extension.upcase
else
format.extension
end
end
disposition ||= "inline"

send_file env, format.to_slice(image),
Expand Down

0 comments on commit 91c2753

Please sign in to comment.