Skip to content

Commit

Permalink
[minor] Remove unnecessary optimization
Browse files Browse the repository at this point in the history
It does not make much sense to optimize for empty messages.
  • Loading branch information
lpinca committed Nov 23, 2019
1 parent f06a738 commit 3293284
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
7 changes: 0 additions & 7 deletions lib/permessage-deflate.js
Expand Up @@ -7,8 +7,6 @@ const bufferUtil = require('./buffer-util');
const { kStatusCode, NOOP } = require('./constants');

const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]);
const EMPTY_BLOCK = Buffer.from([0x00]);

const kPerMessageDeflate = Symbol('permessage-deflate');
const kTotalLength = Symbol('total-length');
const kCallback = Symbol('callback');
Expand Down Expand Up @@ -393,11 +391,6 @@ class PerMessageDeflate {
* @private
*/
_compress(data, fin, callback) {
if (!data || data.length === 0) {
process.nextTick(callback, null, EMPTY_BLOCK);
return;
}

const endpoint = this._isServer ? 'server' : 'client';

if (!this._deflate) {
Expand Down
2 changes: 1 addition & 1 deletion test/sender.test.js
Expand Up @@ -154,7 +154,7 @@ describe('Sender', () => {

assert.strictEqual(chunks[0].length, 2);
assert.strictEqual(chunks[0][0] & 0x40, 0x40);
assert.strictEqual(chunks[1].length, 1);
assert.strictEqual(chunks[1].length, 5);

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

0 comments on commit 3293284

Please sign in to comment.