Skip to content

Commit 3293284

Browse files
committed
[minor] Remove unnecessary optimization
It does not make much sense to optimize for empty messages.
1 parent f06a738 commit 3293284

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

lib/permessage-deflate.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ const bufferUtil = require('./buffer-util');
77
const { kStatusCode, NOOP } = require('./constants');
88

99
const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]);
10-
const EMPTY_BLOCK = Buffer.from([0x00]);
11-
1210
const kPerMessageDeflate = Symbol('permessage-deflate');
1311
const kTotalLength = Symbol('total-length');
1412
const kCallback = Symbol('callback');
@@ -393,11 +391,6 @@ class PerMessageDeflate {
393391
* @private
394392
*/
395393
_compress(data, fin, callback) {
396-
if (!data || data.length === 0) {
397-
process.nextTick(callback, null, EMPTY_BLOCK);
398-
return;
399-
}
400-
401394
const endpoint = this._isServer ? 'server' : 'client';
402395

403396
if (!this._deflate) {

test/sender.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ describe('Sender', () => {
154154

155155
assert.strictEqual(chunks[0].length, 2);
156156
assert.strictEqual(chunks[0][0] & 0x40, 0x40);
157-
assert.strictEqual(chunks[1].length, 1);
157+
assert.strictEqual(chunks[1].length, 5);
158158

159159
assert.strictEqual(chunks[2].length, 2);
160160
assert.strictEqual(chunks[2][0] & 0x40, 0x00);

0 commit comments

Comments
 (0)