From 042ebaa2822400d8cab69c51126f61f131ecfc8e Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Thu, 28 Apr 2022 16:56:32 +0200 Subject: naming cleanup --- zencore/iobuffer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zencore/iobuffer.cpp b/zencore/iobuffer.cpp index c069aa0f1..ccf92da62 100644 --- a/zencore/iobuffer.cpp +++ b/zencore/iobuffer.cpp @@ -226,14 +226,17 @@ IoBufferExtendedCore::~IoBufferExtendedCore() m_DataPtr = nullptr; } -static RwLock g_MappingLock[0x40]; +static constexpr size_t MappingLockCount = 64; +static_assert((MappingLockCount & (MappingLockCount - 1)) == 0, "MappingLockCount must be power of two"); + +static RwLock g_MappingLocks[MappingLockCount]; static RwLock& MappingLockForInstance(const IoBufferExtendedCore* instance) { intptr_t base = (intptr_t)instance; - size_t lock_index = ((base >> 8) ^ (base >> 16)) & 0x3f; - return g_MappingLock[lock_index]; + size_t lock_index = ((base >> 8) ^ (base >> 16)) & (MappingLockCount - 1u); + return g_MappingLocks[lock_index]; } void -- cgit v1.2.3 From f9f58ce2f568d8e3d39acad746242bbe340f68cc Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 29 Apr 2022 08:52:01 +0200 Subject: use IsPow2 for mapping lock count --- zencore/iobuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zencore/iobuffer.cpp b/zencore/iobuffer.cpp index ccf92da62..46b9ab336 100644 --- a/zencore/iobuffer.cpp +++ b/zencore/iobuffer.cpp @@ -227,7 +227,7 @@ IoBufferExtendedCore::~IoBufferExtendedCore() } static constexpr size_t MappingLockCount = 64; -static_assert((MappingLockCount & (MappingLockCount - 1)) == 0, "MappingLockCount must be power of two"); +static_assert(IsPow2(MappingLockCount), "MappingLockCount must be power of two"); static RwLock g_MappingLocks[MappingLockCount]; -- cgit v1.2.3 From cfbd92d50918d45583d970baf938c0e634e12d95 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 29 Apr 2022 08:57:01 +0200 Subject: mac compilation fix --- zenserver/cache/structuredcache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index 8daf08bff..e1d9de976 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -1527,7 +1527,7 @@ HttpStructuredCacheService::HandleRpcGetCacheValues(zen::HttpServerRequest& Http for (size_t Index : RemoteRequestIndexes) { RequestData& Request = Requests[Index]; - RequestedRecordsData.push_back({Request.Key.Bucket, Request.Key.Hash}); + RequestedRecordsData.push_back({{Request.Key.Bucket, Request.Key.Hash}}); CacheChunkRequests.push_back(&RequestedRecordsData.back()); } Stopwatch Timer; -- cgit v1.2.3