diff options
author | Seth Brenith <sethb@microsoft.com> | 2018-01-23 16:04:17 -0800 |
---|---|---|
committer | Jon Moss <me@jonathanmoss.me> | 2018-01-26 16:24:50 -0500 |
commit | aba6bc34a186ff03ff19a1b4026e04cea7c330e3 (patch) | |
tree | b79643e4c8ff478665c157112b5d7cdb59e95ffe /lib/_http_outgoing.js | |
parent | 6c1906ab3e0093a4f5c765de5a709abbe6b32d6b (diff) | |
download | android-node-v8-aba6bc34a186ff03ff19a1b4026e04cea7c330e3.tar.gz android-node-v8-aba6bc34a186ff03ff19a1b4026e04cea7c330e3.tar.bz2 android-node-v8-aba6bc34a186ff03ff19a1b4026e04cea7c330e3.zip |
http: switch on string values
Long ago, V8 was much faster switching on string lengths than values.
That is no longer the case, so we can simplify a couple of methods.
PR-URL: https://github.com/nodejs/node/pull/18351
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Diffstat (limited to 'lib/_http_outgoing.js')
-rw-r--r-- | lib/_http_outgoing.js | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 79d38db291..5f4e8e2cf1 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -510,18 +510,15 @@ OutgoingMessage.prototype.setHeader = function setHeader(name, value) { const key = name.toLowerCase(); this[outHeadersKey][key] = [name, value]; - switch (key.length) { - case 10: - if (key === 'connection') - this._removedConnection = false; + switch (key) { + case 'connection': + this._removedConnection = false; break; - case 14: - if (key === 'content-length') - this._removedContLen = false; + case 'content-length': + this._removedContLen = false; break; - case 17: - if (key === 'transfer-encoding') - this._removedTE = false; + case 'transfer-encoding': + this._removedTE = false; break; } }; @@ -583,22 +580,18 @@ OutgoingMessage.prototype.removeHeader = function removeHeader(name) { var key = name.toLowerCase(); - switch (key.length) { - case 10: - if (key === 'connection') - this._removedConnection = true; + switch (key) { + case 'connection': + this._removedConnection = true; break; - case 14: - if (key === 'content-length') - this._removedContLen = true; + case 'content-length': + this._removedContLen = true; break; - case 17: - if (key === 'transfer-encoding') - this._removedTE = true; + case 'transfer-encoding': + this._removedTE = true; break; - case 4: - if (key === 'date') - this.sendDate = false; + case 'date': + this.sendDate = false; break; } |