优化ECS

This commit is contained in:
dgflash
2026-05-10 21:44:38 +08:00
parent a829dde974
commit 3a61f0420f

View File

@@ -58,18 +58,6 @@ export class ECSDynamicPool<T> {
this.metrics.currentSize = this.pool.length;
}
/**
* 预热池,提前创建指定数量的对象
* @param count 要预热的对象数量
*/
preWarm(count: number): void {
while (this.pool.length < count) {
this.pool.push(this.factory());
this.metrics.createCount++;
}
this.metrics.currentSize = this.pool.length;
}
/**
* 获取池的统计信息
* @returns 只读的统计指标对象
@@ -85,24 +73,4 @@ export class ECSDynamicPool<T> {
this.pool.length = 0;
this.metrics.currentSize = 0;
}
/**
* 手动缩减池大小到指定容量
* @param targetSize 目标池大小
* @returns 移除的对象数量
*/
shrinkTo(targetSize: number): number {
let removed = 0;
while (this.pool.length > targetSize) {
this.pool.pop();
removed++;
}
if (removed > 0) {
this.metrics.currentSize = this.pool.length;
}
return removed;
}
}