Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Some small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Oct 7, 2011
1 parent 626a258 commit 59999c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
4 changes: 3 additions & 1 deletion lib/http.js
Expand Up @@ -825,7 +825,9 @@ ServerResponse.prototype.writeHead = function(statusCode) {

} else {
// handle object case
for (var k in obj) {
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
var k = keys[i];
if (k) headers[k] = obj[k];
}
}
Expand Down
19 changes: 7 additions & 12 deletions lib/net_uv.js
Expand Up @@ -368,18 +368,13 @@ Socket.prototype.write = function(data, arg1, arg2) {

// parse arguments
if (arg1) {
switch (typeof arg1) {
case 'string':
encoding = arg1;
cb = arg2;
break;

case 'function':
cb = arg1;
break;

default:
throw new Error("bad arg");
if (typeof arg1 === 'string') {
encoding = arg1;
cb = arg2;
} else if (typeof arg1 === 'function') {
cb = arg1;
} else {
throw new Error("bad arg");
}
}

Expand Down

0 comments on commit 59999c1

Please sign in to comment.