Skip to content

Commit

Permalink
perf: use strict equality when possible
Browse files Browse the repository at this point in the history
closes #2722
  • Loading branch information
Ángel Sanz authored and dougwilson committed May 31, 2016
1 parent c6039af commit b69b760
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ unreleased
- deps: ipaddr.js@1.1.1
* deps: vary@~1.1.0
- Only accept valid field names in the `field` argument
* perf: use strict equality when possible

4.13.4 / 2016-01-21
===================
Expand Down
6 changes: 3 additions & 3 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ defineGetter(req, 'protocol', function protocol(){
/**
* Short-hand for:
*
* req.protocol == 'https'
* req.protocol === 'https'
*
* @return {Boolean}
* @public
Expand Down Expand Up @@ -437,10 +437,10 @@ defineGetter(req, 'fresh', function(){
var s = this.res.statusCode;

// GET or HEAD for weak freshness validation only
if ('GET' != method && 'HEAD' != method) return false;
if ('GET' !== method && 'HEAD' !== method) return false;

// 2xx or 304 as per rfc2616 14.26
if ((s >= 200 && s < 300) || 304 == s) {
if ((s >= 200 && s < 300) || 304 === s) {
return fresh(this.headers, (this.res._headers || {}));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ res.send = function send(body) {
if (req.fresh) this.statusCode = 304;

// strip irrelevant headers
if (204 == this.statusCode || 304 == this.statusCode) {
if (204 === this.statusCode || 304 === this.statusCode) {
this.removeHeader('Content-Type');
this.removeHeader('Content-Length');
this.removeHeader('Transfer-Encoding');
Expand Down
2 changes: 1 addition & 1 deletion lib/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ proto.param = function param(name, fn) {

// ensure we end up with a
// middleware function
if ('function' != typeof fn) {
if ('function' !== typeof fn) {
throw new Error('invalid param() call for ' + name + ', got ' + fn);
}

Expand Down
8 changes: 4 additions & 4 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ exports.wetag = function wetag(body, encoding){
*/

exports.isAbsolute = function(path){
if ('/' == path[0]) return true;
if (':' == path[1] && '\\' == path[2]) return true;
if ('\\\\' == path.substring(0, 2)) return true; // Microsoft Azure absolute path
if ('/' === path[0]) return true;
if (':' === path[1] && '\\' === path[2]) return true;
if ('\\\\' === path.substring(0, 2)) return true; // Microsoft Azure absolute path
};

/**
Expand Down Expand Up @@ -142,7 +142,7 @@ function acceptParams(str, index) {

for (var i = 1; i < parts.length; ++i) {
var pms = parts[i].split(/ *= */);
if ('q' == pms[0]) {
if ('q' === pms[0]) {
ret.quality = parseFloat(pms[1]);
} else {
ret.params[pms[0]] = pms[1];
Expand Down

0 comments on commit b69b760

Please sign in to comment.