From 91c27535921f4a8049a1874c03de3c50a17b8b28 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sun, 16 Jun 2024 22:29:58 +0200 Subject: [PATCH] Use `String.build` instead of concatenation --- src/ext/kemal_gphoto2.cr | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/ext/kemal_gphoto2.cr b/src/ext/kemal_gphoto2.cr index 967a9ec..de0d44f 100644 --- a/src/ext/kemal_gphoto2.cr +++ b/src/ext/kemal_gphoto2.cr @@ -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),