Replace nlohmann/json with native C++20 JSON engine, cut build RAM/time, fix 32-bit build, enable -O2 -march=native

This commit is contained in:
Luxferre
2026-10-14 08:36:39 +03:00
parent 3e70adeb8b
commit 39d7640a5a
11 changed files with 910 additions and 25919 deletions
+31
View File
@@ -324,6 +324,37 @@ int to_int_val(std::string_view s, int def) {
return (int)v;
}
bool read_file_str(std::string_view path, std::string &out) {
out.clear();
std::string p(path);
FILE *f = std::fopen(p.c_str(), "rb");
if (!f) return false;
char buf[4096];
size_t n;
while ((n = std::fread(buf, 1, sizeof buf, f)) > 0) {
out.append(buf, n);
}
bool ok = (std::ferror(f) == 0);
std::fclose(f);
return ok;
}
bool write_file_str(std::string_view path, std::string_view data) {
std::string p(path);
FILE *f = std::fopen(p.c_str(), "wb");
if (!f) return false;
size_t written = 0;
while (written < data.size()) {
size_t n = std::fwrite(data.data() + written, 1, data.size() - written, f);
if (n == 0) {
std::fclose(f);
return false;
}
written += n;
}
return std::fclose(f) == 0;
}
/* ----------------------------- signal --------------------------------- */
static void sigint_handler(int sig) {
(void)sig;