diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-29 09:03:40 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-04-29 09:03:40 +0200 |
| commit | d2b4a38055b44c5141c0ec84796ccf65968563c8 (patch) | |
| tree | 13cf6fd6ca61f7eafed6b440ffdce18ad2e48e14 /zencore/iobuffer.cpp | |
| parent | Merge pull request #83 from EpicGames/de/minor-optimizations (diff) | |
| parent | mac compilation fix (diff) | |
| download | zen-1.0.0.8.tar.xz zen-1.0.0.8.zip | |
Merge pull request #84 from EpicGames/de/cleanup-lock-sharding-in-iobufferv1.0.0.8
iobuffer lock sharding cleanup
Diffstat (limited to 'zencore/iobuffer.cpp')
| -rw-r--r-- | zencore/iobuffer.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/zencore/iobuffer.cpp b/zencore/iobuffer.cpp index c069aa0f1..46b9ab336 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(IsPow2(MappingLockCount), "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 |