Skip to content

Commit

Permalink
[perf] Reset compressor/decompressor instead of re-initialize (#1840)
Browse files Browse the repository at this point in the history
  • Loading branch information
cTn-dev committed Feb 2, 2021
1 parent 2789887 commit 4e9607b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/permessage-deflate.js
Expand Up @@ -376,12 +376,11 @@ class PerMessageDeflate {
this._inflate[kTotalLength]
);

this._inflate[kTotalLength] = 0;
this._inflate[kBuffers] = [];

if (fin && this.params[`${endpoint}_no_context_takeover`]) {
this._inflate.close();
this._inflate = null;
} else {
this._inflate[kTotalLength] = 0;
this._inflate[kBuffers] = [];
this._inflate.reset();
}

callback(null, data);
Expand Down Expand Up @@ -448,12 +447,11 @@ class PerMessageDeflate {
//
this._deflate[kCallback] = null;

this._deflate[kTotalLength] = 0;
this._deflate[kBuffers] = [];

if (fin && this.params[`${endpoint}_no_context_takeover`]) {
this._deflate.close();
this._deflate = null;
} else {
this._deflate[kTotalLength] = 0;
this._deflate[kBuffers] = [];
this._deflate.reset();
}

callback(null, data);
Expand Down

0 comments on commit 4e9607b

Please sign in to comment.