diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-06 15:07:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-06 15:07:17 +0100 |
| commit | f05ce923c4d8ab7bb0d37063b532f7a0cec0ac1e (patch) | |
| tree | 598abce7a3900717f93e6730a7e0627cd1e8bb10 /dev | |
| parent | d490c134c382720038dd9ac6b59aa094daa699d6 (diff) | |
| parent | 51d8c4be180d013455fd8739aff595f9416a7d3f (diff) | |
Merge pull request #17 from 2LoS/fixes
Minor changes
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/CompilerKit/UUID.h | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/dev/CompilerKit/UUID.h b/dev/CompilerKit/UUID.h index 39db276..1218fab 100644 --- a/dev/CompilerKit/UUID.h +++ b/dev/CompilerKit/UUID.h @@ -3,6 +3,7 @@ #include <array> #include <atomic> +#include <cctype> #include <chrono> #include <cstring> #include <functional> @@ -85,16 +86,8 @@ namespace Detail { } template <typename TChar> - [[nodiscard]] constexpr inline bool is_hex(TChar const ch) noexcept { - return (ch >= static_cast<TChar>('0') && ch <= static_cast<TChar>('9')) || - (ch >= static_cast<TChar>('a') && ch <= static_cast<TChar>('f')) || - (ch >= static_cast<TChar>('A') && ch <= static_cast<TChar>('F')); - } - - template <typename TChar> [[nodiscard]] constexpr std::basic_string_view<TChar> to_string_view(TChar const* str) noexcept { - if (str) return str; - return {}; + return str; } template <typename StringType> @@ -437,7 +430,7 @@ class uuid { for (size_t i = hasBraces; i < str.size() - hasBraces; ++i) { if (str[i] == '-') continue; - if (index >= 16 || !Detail::is_hex(str[i])) { + if (index >= 16 || !std::isxdigit(static_cast<unsigned char>(str[i]))) { return false; } @@ -474,7 +467,7 @@ class uuid { for (size_t i = hasBraces; i < str.size() - hasBraces; ++i) { if (str[i] == '-') continue; - if (index >= 16 || !Detail::is_hex(str[i])) { + if (index >= 16 || !std::isxdigit(static_cast<unsigned char>(str[i]))) { return {}; } @@ -600,11 +593,10 @@ class uuid_system_generator { static_cast<unsigned char>((newId.Data1 >> 16) & 0xFF), static_cast<unsigned char>((newId.Data1 >> 8) & 0xFF), static_cast<unsigned char>((newId.Data1) & 0xFF), - - (unsigned char) ((newId.Data2 >> 8) & 0xFF), (unsigned char) ((newId.Data2) & 0xFF), - - (unsigned char) ((newId.Data3 >> 8) & 0xFF), (unsigned char) ((newId.Data3) & 0xFF), - + static_cast<unsigned char>((newId.Data2 >> 8) & 0xFF), + static_cast<unsigned char>((newId.Data2) & 0xFF), + static_cast<unsigned char>((newId.Data3 >> 8) & 0xFF), + static_cast<unsigned char>((newId.Data3) & 0xFF), newId.Data4[0], newId.Data4[1], newId.Data4[2], newId.Data4[3], newId.Data4[4], newId.Data4[5], newId.Data4[6], newId.Data4[7]}}; @@ -832,4 +824,4 @@ struct hash<uuids::uuid> { }; } // namespace std -#endif /* STDUUID_H */
\ No newline at end of file +#endif /* STDUUID_H */ |
