Skip to content

Commit

Permalink
[perf] Reduce buffer allocations
Browse files Browse the repository at this point in the history
Do not convert strings to `Buffer`s if data does not need to be masked.

Refs: #1998
  • Loading branch information
lpinca committed Jan 7, 2022
1 parent 4081a36 commit dbb0cf4
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 119 deletions.
4 changes: 2 additions & 2 deletions lib/permessage-deflate.js
Expand Up @@ -313,7 +313,7 @@ class PerMessageDeflate {
/**
* Compress data. Concurrency limited.
*
* @param {Buffer} data Data to compress
* @param {(Buffer|String)} data Data to compress
* @param {Boolean} fin Specifies whether or not this is the last fragment
* @param {Function} callback Callback
* @public
Expand Down Expand Up @@ -395,7 +395,7 @@ class PerMessageDeflate {
/**
* Compress data.
*
* @param {Buffer} data Data to compress
* @param {(Buffer|String)} data Data to compress
* @param {Boolean} fin Specifies whether or not this is the last fragment
* @param {Function} callback Callback
* @private
Expand Down

0 comments on commit dbb0cf4

Please sign in to comment.