Minor performance improve (#2916)

* only check in debug mode

* undo unneeded modification
This commit is contained in:
minggo
2020-10-16 17:53:24 +08:00
committed by GitHub
parent 0cccd2c30f
commit 5dc8027ef0
2 changed files with 6 additions and 2 deletions
+2 -1
View File
@@ -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;
+4 -1
View File
@@ -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);