mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
http: reduce raw header name allocations
Reuse the values array instead of allocating a second result array. Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com> PR-URL: https://github.com/nodejs/node/pull/66488 Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Tim Perry <pimterry@gmail.com>
This commit is contained in:
1 parent
63c1bfcc86
commit
a64265166c
3 files changed
+79
-5
No files matched your search
@@ -22,7 +22,6 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Array,
|
||||
ArrayIsArray,
|
||||
MathFloor,
|
||||
ObjectDefineProperty,
|
||||
@@ -928,12 +927,11 @@ OutgoingMessage.prototype.getRawHeaderNames = function getRawHeaderNames() {
|
||||
const headersMap = this[kOutHeaders];
|
||||
if (headersMap === null) return [];
|
||||
|
||||
const values = ObjectValues(headersMap);
|
||||
const headers = Array(values.length);
|
||||
const headers = 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];
|
||||
for (let i = 0; i < headers.length; i++) {
|
||||
headers[i] = headers[i][0];
|
||||
}
|
||||
|
||||
return headers;
|
||||
|
||||
Reference in new issue
Block a user