Skip to content

Commit

Permalink
Remove zlib pooling, destroy on close instead
Browse files Browse the repository at this point in the history
We do not need this optimization since SPDY isn't really done at scale
anymore.
  • Loading branch information
danopia committed Aug 14, 2023
1 parent 56b137c commit 1d05c8e
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions lib/spdy-transport/protocol/spdy/zlib-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,24 @@ export type CompressionPair = {

export class CompressionPool {
compression: boolean;
pool: { 2: CompressionPair[]; 3: CompressionPair[]; 3.1: CompressionPair[]; };
constructor (compression: boolean) {
this.compression = compression
this.pool = {
2: [],
3: [],
3.1: []
}
}

static create (compression: boolean) {
return new CompressionPool(compression)
}

get (version: 2|3|3.1) {
if (this.pool[version].length > 0) {
return this.pool[version].pop()!
} else {
const id = version

return {
version: version,
compress: _createDeflate(id, this.compression),
decompress: _createInflate(id),
}
return {
version: version,
compress: _createDeflate(version, this.compression),
decompress: _createInflate(version),
}
}

put (pair: CompressionPair) {
this.pool[pair.version].push(pair)
pair.compress.close();
pair.decompress.close();
}
}

0 comments on commit 1d05c8e

Please sign in to comment.