From e798e30cf23252236e1955ab81f4b21cdd8b0e32 Mon Sep 17 00:00:00 2001 From: MaggotHATE Date: Wed, 6 Dec 2023 19:06:58 +0500 Subject: [PATCH] Simplify reading --- common/common.cpp | 7 +++---- common/common.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index 72600f9b0..bfb42da87 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -115,9 +115,9 @@ void process_escapes(std::string& input) { input.resize(output_idx); } -nlohmann::json get_json(std::string& file_name) noexcept { +nlohmann::json get_json(const char* file_name) noexcept { try { - printf("Opening a json file %s\n", file_name.c_str()); + printf("Opening a json file %s\n", file_name); std::ifstream jstream(file_name); return nlohmann::json::parse(jstream); } @@ -136,8 +136,7 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) { // only the second argument to reduce reading attempts (plus drag'n'drop) if (argc > 1) { // console arguments should override json values, so json processing goes first - std::string json_name = argv[1]; - nlohmann::json file_config = get_json(json_name); + nlohmann::json file_config = get_json(argv[1]); pos = 2; // avoid putting file name into arguments if (!file_config.empty()) { diff --git a/common/common.h b/common/common.h index 5327bf5e7..50026cd09 100644 --- a/common/common.h +++ b/common/common.h @@ -133,7 +133,7 @@ struct gpt_params { std::string image = ""; // path to an image file }; -nlohmann::json get_json(std::string& file_name) noexcept; +nlohmann::json get_json(const char* file_name) noexcept; bool gpt_params_parse_ex(int argc, char ** argv, gpt_params & params);