From 684e862e13a8d12f3a9b993abb9135e9331dca0e Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Sun, 13 Oct 2024 21:51:24 +0200 Subject: [PATCH] Simplify `Submission#command_for` The previous mechanism always cycled through all files once again, just to identify the very same file and using an attribute passed to the method. This can be simplified with the given refactoring. --- app/models/submission.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/submission.rb b/app/models/submission.rb index 7c38c9aa0..e93c722b4 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -248,8 +248,7 @@ def swap_runner(old_runner) [new_runner, new_waiting_duration] end - def command_for(template, file) - filepath = collect_files.find {|f| f.filepath == file }.filepath + def command_for(template, filepath) template % command_substitutions(filepath) end