diff --git a/native/cocos/bindings/dop/BufferAllocator.h b/native/cocos/bindings/dop/BufferAllocator.h index 021475a22d..e763126b9d 100644 --- a/native/cocos/bindings/dop/BufferAllocator.h +++ b/native/cocos/bindings/dop/BufferAllocator.h @@ -31,7 +31,7 @@ public: template static T *getBuffer(PoolType type, uint index, uint *size) { - index &= ~(1 << 30); + index &= _bufferMask; if (BufferAllocator::_pools.count(type) != 0) { const auto pool = BufferAllocator::_pools[type]; if (pool->_buffers.count(index) != 0) { @@ -56,6 +56,7 @@ public: private: static cc::map _pools; + static constexpr uint _bufferMask = ~(1 << 30); cc::map _buffers; PoolType _type = PoolType::UNKNOWN; diff --git a/native/cocos/bindings/dop/ObjectPool.h b/native/cocos/bindings/dop/ObjectPool.h index 72e73b7282..12378936c9 100644 --- a/native/cocos/bindings/dop/ObjectPool.h +++ b/native/cocos/bindings/dop/ObjectPool.h @@ -43,9 +43,12 @@ public: template Type *getTypedObject(uint id) const { id = _indexMask & id; + bool ok = true; +#ifdef CC_DEBUG uint len = 0; - bool ok = _jsArr->getArrayLength(&len); + ok = _jsArr->getArrayLength(&len); CCASSERT(ok && id < len, "ObjectPool: Invalid buffer pool entry id"); +#endif se::Value jsEntry; ok = _jsArr->getArrayElement(id, &jsEntry);