Some small optimizations

This commit is contained in:
Bert Belder 2011-10-07 03:07:45 +02:00 committed by Ryan Dahl
parent 29ec850478
commit 153629c99a
2 changed files with 10 additions and 13 deletions

View File

@ -825,7 +825,9 @@ ServerResponse.prototype.writeHead = function(statusCode) {
} else { } else {
// handle object case // 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]; if (k) headers[k] = obj[k];
} }
} }

View File

@ -371,17 +371,12 @@ Socket.prototype.write = function(data, arg1, arg2) {
// parse arguments // parse arguments
if (arg1) { if (arg1) {
switch (typeof arg1) { if (typeof arg1 === 'string') {
case 'string':
encoding = arg1; encoding = arg1;
cb = arg2; cb = arg2;
break; } else if (typeof arg1 === 'function') {
case 'function':
cb = arg1; cb = arg1;
break; } else {
default:
throw new Error("bad arg"); throw new Error("bad arg");
} }
} }