speed ts up

This commit is contained in:
2026-01-02 12:43:53 +01:00
parent 58f5578de0
commit abda377808

View File

@@ -1,11 +1,10 @@
#ifndef UTILS_HPP
#define UTILS_HPP
#include <array>
#include <charconv>
#include <cstdint>
#include <filesystem>
#include <format>
#include <string>
namespace utils {
@@ -39,9 +38,12 @@ inline void fastReadNum(const std::string& path, char (&buf)[N], T& result) {
}
inline std::string pNum(const auto num, const uint8_t decs = 0) {
return std::format("{:.{}f}", num, decs);
static std::array<char, 20> buf;
auto [ptr, ec] = std::to_chars(buf.data(), buf.data() + buf.size(), num, std::chars_format::fixed, decs);
return std::string(buf.data(), ptr);
}
inline bool fileExists(const std::string_view& path) {
return std::filesystem::exists(path);
}