diff options
| author | Martin Ridgers <[email protected]> | 2021-10-15 16:04:56 +0200 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-10-15 16:04:56 +0200 |
| commit | 402dfddf62d979319038801a926809e33839e096 (patch) | |
| tree | e8a8e99c7f4718a5fcc363245cc19e16a41bea25 /zencore/include | |
| parent | If/def around Windows-only headers (diff) | |
| parent | httpasio: Implemented support for specifying accept type via url suffix (diff) | |
| download | zen-402dfddf62d979319038801a926809e33839e096.tar.xz zen-402dfddf62d979319038801a926809e33839e096.zip | |
Merged main
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/iobuffer.h | 1 | ||||
| -rw-r--r-- | zencore/include/zencore/stats.h | 2 | ||||
| -rw-r--r-- | zencore/include/zencore/string.h | 22 | ||||
| -rw-r--r-- | zencore/include/zencore/thread.h | 3 |
4 files changed, 23 insertions, 5 deletions
diff --git a/zencore/include/zencore/iobuffer.h b/zencore/include/zencore/iobuffer.h index 380199066..60fee1dc5 100644 --- a/zencore/include/zencore/iobuffer.h +++ b/zencore/include/zencore/iobuffer.h @@ -372,6 +372,7 @@ public: ZENCORE_API static IoBuffer MakeFromFile(const std::filesystem::path& FileName, uint64_t Offset = 0, uint64_t Size = ~0ull); ZENCORE_API static IoBuffer MakeFromTemporaryFile(const std::filesystem::path& FileName); ZENCORE_API static IoBuffer MakeFromFileHandle(void* FileHandle, uint64_t Offset = 0, uint64_t Size = ~0ull); + ZENCORE_API static IoBuffer ReadFromFileMaybe(IoBuffer& InBuffer); inline static IoBuffer MakeCloneFromMemory(const void* Ptr, size_t Sz) { return IoBuffer(IoBuffer::Clone, Ptr, Sz); } }; diff --git a/zencore/include/zencore/stats.h b/zencore/include/zencore/stats.h index 884bb53f6..d58435a20 100644 --- a/zencore/include/zencore/stats.h +++ b/zencore/include/zencore/stats.h @@ -223,7 +223,7 @@ private: /** Metrics for network requests - Aggregates tracking of duration, payload sizes into a single + Aggregates tracking of duration, payload sizes into a single class */ diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h index fa22c3540..e2a957786 100644 --- a/zencore/include/zencore/string.h +++ b/zencore/include/zencore/string.h @@ -618,9 +618,23 @@ HashStringDjb2(const std::string_view& InString) { uint32_t HashValue = 5381; - for (int c : InString) + for (int CurChar : InString) { - HashValue = HashValue * 33 + c; + HashValue = HashValue * 33 + CurChar; + } + + return HashValue; +} + +constexpr uint32_t +HashStringAsLowerDjb2(const std::string_view& InString) +{ + uint32_t HashValue = 5381; + + for (int CurChar : InString) + { + CurChar -= ((CurChar - 'A') <= ('Z' - 'A')) * ('A' - 'a'); // this should be compiled into branchless logic + HashValue = HashValue * 33 + CurChar; } return HashValue; @@ -633,9 +647,9 @@ ToLower(const std::string_view& InString) { std::string Out(InString); - for (char& C : Out) + for (char& CurChar : Out) { - C = static_cast<char>(std::tolower(C)); + CurChar -= ((CurChar - 'A') <= ('Z' - 'A')) * ('A' - 'a'); // this should be compiled into branchless logic } return Out; diff --git a/zencore/include/zencore/thread.h b/zencore/include/zencore/thread.h index f677113a0..48a58a261 100644 --- a/zencore/include/zencore/thread.h +++ b/zencore/include/zencore/thread.h @@ -6,10 +6,13 @@ #include <shared_mutex> +#include <string_view> #include <vector> namespace zen { +void SetCurrentThreadName(std::string_view ThreadName); + /** * Reader-writer lock * |