浏览代码

fix magic numbers

/main
xingwei.zhu 5 年前
当前提交
84608bf5
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 9
      Runtime/ui/renderer/allocator/pool_object.cs

9
Runtime/ui/renderer/allocator/pool_object.cs


public static class ObjectPool<TObject> where TObject : PoolObject, new() {
static readonly Stack<TObject> pool = new Stack<TObject>();
const int POOL_MAX_SIZE = 256;
const int POOL_BATCH_SIZE = 128;
for (int i = 0; i < 128; i++) {
for (int i = 0; i < POOL_BATCH_SIZE; i++) {
allocatedCount += 128;
allocatedCount += POOL_BATCH_SIZE;
}
var ret = pool.Pop();

}
obj.clear();
if (pool.Count > 256) {
if (pool.Count > POOL_MAX_SIZE) {
allocatedCount--;
//there are enough items in the pool
//just release the obj to GC

正在加载...
取消
保存