mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
Minor performance improve (#2916)
* only check in debug mode * undo unneeded modification
This commit is contained in:
@@ -31,7 +31,7 @@ public:
|
||||
|
||||
template <class T>
|
||||
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<PoolType, BufferAllocator *> _pools;
|
||||
static constexpr uint _bufferMask = ~(1 << 30);
|
||||
|
||||
cc::map<uint, Object *> _buffers;
|
||||
PoolType _type = PoolType::UNKNOWN;
|
||||
|
||||
@@ -43,9 +43,12 @@ public:
|
||||
template <class Type>
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user