Skip to content

Commit 5b7fbb0

Browse files
authored
[perf] Reduce buffer allocations (#2000)
Do not convert strings to `Buffer`s if data does not need to be masked. Refs: #1998
1 parent 8de448f commit 5b7fbb0

File tree

3 files changed

+146
-119
lines changed

3 files changed

+146
-119
lines changed

lib/permessage-deflate.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class PerMessageDeflate {
313313
/**
314314
* Compress data. Concurrency limited.
315315
*
316-
* @param {Buffer} data Data to compress
316+
* @param {(Buffer|String)} data Data to compress
317317
* @param {Boolean} fin Specifies whether or not this is the last fragment
318318
* @param {Function} callback Callback
319319
* @public
@@ -395,7 +395,7 @@ class PerMessageDeflate {
395395
/**
396396
* Compress data.
397397
*
398-
* @param {Buffer} data Data to compress
398+
* @param {(Buffer|String)} data Data to compress
399399
* @param {Boolean} fin Specifies whether or not this is the last fragment
400400
* @param {Function} callback Callback
401401
* @private

0 commit comments

Comments
 (0)