diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-28 16:56:32 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-04-28 16:56:32 +0200 |
| commit | 042ebaa2822400d8cab69c51126f61f131ecfc8e (patch) | |
| tree | 7c3a4adda4824c97799f160b303b90f32b398ca0 /zencore/iobuffer.cpp | |
| parent | Reduce risk of reallocating backing std::vector in CbWriter::AddBinary (diff) | |
| download | zen-042ebaa2822400d8cab69c51126f61f131ecfc8e.tar.xz zen-042ebaa2822400d8cab69c51126f61f131ecfc8e.zip | |
naming 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..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 |