diff options
| author | Stefan Boberg <[email protected]> | 2021-10-14 19:07:14 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-14 19:07:14 +0200 |
| commit | 2b71d6a8d57c773bc7734b253a1ffd1e47162184 (patch) | |
| tree | c0c70f9f2f8b9dc895080aac9f7de1140c56ebf0 /zencore/include | |
| parent | Merge branch 'main' of https://github.com/EpicGames/zen (diff) | |
| download | zen-2b71d6a8d57c773bc7734b253a1ffd1e47162184.tar.xz zen-2b71d6a8d57c773bc7734b253a1ffd1e47162184.zip | |
asio HTTP implementation (#23)
asio-based HTTP implementation
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/iobuffer.h | 1 | ||||
| -rw-r--r-- | zencore/include/zencore/string.h | 22 | ||||
| -rw-r--r-- | zencore/include/zencore/thread.h | 3 |
3 files changed, 22 insertions, 4 deletions
diff --git a/zencore/include/zencore/iobuffer.h b/zencore/include/zencore/iobuffer.h index 5fbeaeaeb..db462e238 100644 --- a/zencore/include/zencore/iobuffer.h +++ b/zencore/include/zencore/iobuffer.h @@ -374,6 +374,7 @@ public: ZENCORE_API static IoBuffer MakeFromFile(const path_char_t* 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/string.h b/zencore/include/zencore/string.h index c205b199d..a94e063a4 100644 --- a/zencore/include/zencore/string.h +++ b/zencore/include/zencore/string.h @@ -619,9 +619,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; @@ -634,9 +648,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 410ffbd1e..9fc4c87a2 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 * |