Skip to content

Commit

Permalink
#1717: args: refactor into seperate functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed May 5, 2022
1 parent 288da6d commit a990069
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/vt/configs/arguments/args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -776,9 +776,7 @@ std::tuple<int, std::string> ArgConfig::parseToConfig(
}

namespace {
static std::string buildFile(
std::string const& file, std::string const& dir, bool add_br_extension
) {
static std::string buildRankFile(std::string const& file) {
std::string name = file;
std::size_t rank = name.find("%p");
auto str_rank = std::to_string(theContext()->getNode());
Expand All @@ -787,22 +785,37 @@ static std::string buildFile(
} else {
name.replace(rank, 2, str_rank);
}
if (add_br_extension) {
if (name.substr(name.length()-3, 3) != ".br") {
name = name + ".br";
}
}
return name;
}

static std::string buildFile(
std::string const& file, std::string const& dir
) {
auto const name = buildRankFile(file);
return dir + "/" + name;
}

static std::string buildFileWithBrExtension(
std::string const& file, std::string const& dir
) {
auto name = buildRankFile(file);
if (name.substr(name.length()-3, 3) != ".br") {
name = name + ".br";
}
return dir + "/" + name;
}
} /* end anon namespace */

std::string AppConfig::getLBStatsFileOut() const {
return buildFile(vt_lb_stats_file, vt_lb_stats_dir, vt_lb_stats_compress);
if (vt_lb_stats_compress) {
return buildFileWithBrExtension(vt_lb_stats_file, vt_lb_stats_dir);
} else {
return buildFile(vt_lb_stats_file, vt_lb_stats_dir);
}
}

std::string AppConfig::getLBStatsFileIn() const {
return buildFile(vt_lb_stats_file_in, vt_lb_stats_dir_in, false);
return buildFile(vt_lb_stats_file_in, vt_lb_stats_dir_in);
}

}} /* end namespace vt::arguments */

0 comments on commit a990069

Please sign in to comment.