speed ts up
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user