Skip to content

Commit

Permalink
[perf] Reduce buffer allocations (#2000)
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 authored Jan 13, 2022
1 parent 8de448f commit 5b7fbb0
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 119 deletions.
4 changes: 2 additions & 2 deletions lib/permessage-deflate.js
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 5b7fbb0

Please sign in to comment.