From 209a9539a008824297375190dbbd45b99f7a8220 Mon Sep 17 00:00:00 2001 From: David Parsons <david.parsons@inria.fr> Date: Fri, 15 Dec 2023 15:42:02 +0100 Subject: [PATCH] extract fn read_sequence --- src/aevol_create.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/aevol_create.cpp b/src/aevol_create.cpp index 638cc0028..4c50b0748 100644 --- a/src/aevol_create.cpp +++ b/src/aevol_create.cpp @@ -176,6 +176,17 @@ void interpret_cmd_line_options(int argc, char* argv[]) { } } +auto read_sequence(std::ifstream& chromosome_file, const std::string& chromosome_file_name) { + std::string chromosome; + + std::getline(chromosome_file, chromosome); + if (not chromosome_file or chromosome.length() == 0) { + Utils::ExitWithUsrMsg(std::string("failed to read from chromosome file ") + chromosome_file_name); + } + + return chromosome; +} + std::list<std::string> read_sequence_file(const std::string& chromosome_file_name) { assert(chromosome_file_name.length() != 0); @@ -186,12 +197,7 @@ std::list<std::string> read_sequence_file(const std::string& chromosome_file_nam Utils::ExitWithUsrMsg(std::string("failed to open source chromosome file ") + chromosome_file_name); } - std::string chromosome; - std::getline(chromosome_file, chromosome); - if (not chromosome_file or chromosome.length() == 0) { - Utils::ExitWithUsrMsg(std::string("failed to read from chromosome file ") + chromosome_file_name); - } - chromosomes.push_back(std::move(chromosome)); + chromosomes.push_back(read_sequence(chromosome_file, chromosome_file_name)); return chromosomes; } -- GitLab