mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-04 02:02:41 +08:00
Fix the bug of trigger assertion in ValueArrayPool::get. (#12499)
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "ValueArrayPool.h"
|
||||
#include "base/Macros.h"
|
||||
#include "base/memory/Memory.h"
|
||||
#include "config.h"
|
||||
|
||||
namespace se {
|
||||
@@ -41,14 +42,15 @@ ValueArrayPool::ValueArrayPool() {
|
||||
}
|
||||
}
|
||||
|
||||
ValueArray &ValueArrayPool::get(uint32_t argc) {
|
||||
ValueArray &ValueArrayPool::get(uint32_t argc, bool &outNeedDelete) {
|
||||
if (SE_UNLIKELY(_depth >= _pools.size())) {
|
||||
auto *ptr = _pools.data();
|
||||
_pools.resize(_depth + 1);
|
||||
CC_ASSERT(_pools.data() == ptr);
|
||||
initPool(_depth);
|
||||
outNeedDelete = true;
|
||||
auto *ret = ccnew ValueArray();
|
||||
ret->resize(argc);
|
||||
return *ret;
|
||||
}
|
||||
|
||||
outNeedDelete = false;
|
||||
CC_ASSERT(argc <= MAX_ARGS);
|
||||
auto &ret = _pools[_depth][argc];
|
||||
CC_ASSERT(ret.size() == argc);
|
||||
|
||||
Reference in New Issue
Block a user