Skip to content

Commit

Permalink
Improve method implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
simov committed Mar 10, 2021
1 parent 933100d commit ecb76b9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/_http_outgoing.js
Expand Up @@ -607,15 +607,14 @@ OutgoingMessage.prototype.getHeaderNames = function getHeaderNames() {
// Returns an array of the names of the current outgoing raw headers.
OutgoingMessage.prototype.getRawHeaderNames = function getRawHeaderNames() {
const headersMap = this[kOutHeaders];
const headers = Array(ObjectKeys(headersMap).length);
if (headersMap === null) return [];

if (headersMap !== null) {
const values = ObjectValues(headersMap);
// Retain for(;;) loop for performance reasons
// Refs: https://github.com/nodejs/node/pull/30958
for (let i = 0, l = values.length; i < l; i++) {
headers[i] = values[i][0];
}
const values = ObjectValues(headersMap);
const headers = Array(values.length);
// Retain for(;;) loop for performance reasons
// Refs: https://github.com/nodejs/node/pull/30958
for (let i = 0, l = values.length; i < l; i++) {
headers[i] = values[i][0];
}

return headers;
Expand Down

0 comments on commit ecb76b9

Please sign in to comment.