MCPcopy Create free account
hub / github.com/Shazbot/WH3-Mod-Manager / returnBuffer

Method returnBuffer

src/packFileSerializer.ts:3270–3286  ·  view source on GitHub ↗
(buffer: Buffer, originalSize: number)

Source from the content-addressed store, hash-verified

3268 return Buffer.allocUnsafe(poolSize);
3269 }
3270 returnBuffer(buffer: Buffer, originalSize: number): void {
3271 const poolSize = Math.max(1024, Math.pow(2, Math.ceil(Math.log2(originalSize))));
3272 // Only return if it's the right size for the pool
3273 if (buffer.length !== poolSize) {
3274 return; // Different size, don't pool it
3275 }
3276 let pool = this.pools.get(poolSize);
3277 if (!pool) {
3278 pool = [];
3279 this.pools.set(poolSize, pool);
3280 }
3281 // Return buffer to pool for reuse (but don't let pool grow too large)
3282 if (pool.length < this.MAX_POOL_SIZE) {
3283 pool.push(buffer);
3284 }
3285 // If pool is full, let buffer get garbage collected
3286 }
3287 // Clear all pools (useful for cleanup)
3288 clear(): void {
3289 this.pools.clear();

Callers 2

flushBatchFunction · 0.80

Calls 1

getMethod · 0.65

Tested by

no test coverage detected