From b6504b663ecb176dcf4bcf90f7c19cb52b85ff5c Mon Sep 17 00:00:00 2001 From: dearblue Date: Tue, 1 Jul 2025 20:40:47 +0900 Subject: [PATCH] Avoid array object creation in `cmd_bin` method in bintest Simply reverse the calling direction of `cmd_bin` method and `cmd_list` method. --- test/bintest.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/bintest.rb b/test/bintest.rb index 5d995ff84..94bdf10ca 100644 --- a/test/bintest.rb +++ b/test/bintest.rb @@ -3,14 +3,17 @@ require 'test/assert.rb' GEMNAME = "" -def cmd_list(s) +def cmd_bin(s) path = s == "mrbc" ? ENV['MRBCFILE'] : "#{ENV['BUILD_DIR']}/bin/#{s}" path = path.sub(/\.exe\z/, "") if /mswin(?!ce)|mingw|bccwin/ =~ RbConfig::CONFIG['host_os'] path = "#{path}.exe".tr("/", "\\") end + path +end - path_list = [path] +def cmd_list(s) + path_list = [cmd_bin(s)] emu = ENV['EMULATOR'] path_list.unshift emu if emu && !emu.empty? @@ -22,10 +25,6 @@ def cmd(s) cmd_list(s).join(' ') end -def cmd_bin(s) - cmd_list(s).pop -end - def shellquote(s) case RbConfig::CONFIG['host_os'] when /mswin(?!ce)|mingw|bccwin/