config_parser: Reduce number of file reads
This changes focuses on reducing the number of Parser() constructions to
limit the number of duplicate file reads.
Change-Id: I05df943844c70dc6aa729ab744d2d405cbfe2c76
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/config_parser.cpp b/src/config_parser.cpp
index b684fa2..27a7b15 100644
--- a/src/config_parser.cpp
+++ b/src/config_parser.cpp
@@ -1,5 +1,8 @@
#include "config_parser.hpp"
+#include <fmt/compile.h>
+#include <fmt/format.h>
+
#include <functional>
#include <iterator>
#include <stdplus/exception.hpp>
@@ -37,6 +40,16 @@
return std::nullopt;
}
+fs::path pathForIntfConf(const fs::path& dir, std::string_view intf)
+{
+ return dir / fmt::format(FMT_COMPILE("00-bmc-{}.network"), intf);
+}
+
+fs::path pathForIntfDev(const fs::path& dir, std::string_view intf)
+{
+ return dir / fmt::format(FMT_COMPILE("{}.netdev"), intf);
+}
+
Parser::Parser(const fs::path& filename)
{
setFile(filename);
@@ -209,6 +222,7 @@
fmt::format("{}: Read error: {}", filename.native(), e.what()));
}
+ this->filename = filename;
this->sections = std::move(parse.sections);
this->warnings = std::move(parse.warnings);
}