summaryrefslogtreecommitdiff
path: root/lib/cluster.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2015-01-28 20:05:53 -0500
committercjihrig <cjihrig@gmail.com>2015-01-31 23:47:29 -0500
commit6ac8bdc0aba5f60f4b4f2da5abd36d664062aa40 (patch)
tree29a3b1ce92cfad3ae5d41a4ba7451846beace950 /lib/cluster.js
parentbce7a2608eb198eee6ecd7991062efd6daeeb440 (diff)
downloadandroid-node-v8-6ac8bdc0aba5f60f4b4f2da5abd36d664062aa40.tar.gz
android-node-v8-6ac8bdc0aba5f60f4b4f2da5abd36d664062aa40.tar.bz2
android-node-v8-6ac8bdc0aba5f60f4b4f2da5abd36d664062aa40.zip
lib: reduce util.is*() usage
Many of the util.is*() methods used to check data types simply compare against a single value or the result of typeof. This commit replaces calls to these methods with equivalent checks. This commit does not touch calls to the more complex methods (isRegExp(), isDate(), etc.). Fixes: https://github.com/iojs/io.js/issues/607 PR-URL: https://github.com/iojs/io.js/pull/647 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib/cluster.js')
-rw-r--r--lib/cluster.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/cluster.js b/lib/cluster.js
index 9312fc28f2..14d0bc69b3 100644
--- a/lib/cluster.js
+++ b/lib/cluster.js
@@ -22,7 +22,7 @@ function Worker(options) {
EventEmitter.call(this);
- if (!util.isObject(options))
+ if (options === null || typeof options !== 'object')
options = {};
this.suicide = undefined;
@@ -68,7 +68,7 @@ function SharedHandle(key, address, port, addressType, backlog, fd) {
else
rval = net._createServerHandle(address, port, addressType, fd);
- if (util.isNumber(rval))
+ if (typeof rval === 'number')
this.errno = rval;
else
this.handle = rval;
@@ -135,7 +135,7 @@ RoundRobinHandle.prototype.add = function(worker, send) {
self.handoff(worker); // In case there are connections pending.
}
- if (util.isNull(this.server)) return done();
+ if (this.server === null) return done();
// Still busy binding.
this.server.once('listening', done);
this.server.once('error', function(err) {
@@ -170,7 +170,7 @@ RoundRobinHandle.prototype.handoff = function(worker) {
return; // Worker is closing (or has closed) the server.
}
var handle = this.handles.shift();
- if (util.isUndefined(handle)) {
+ if (handle === undefined) {
this.free.push(worker); // Add to ready queue again.
return;
}
@@ -203,7 +203,7 @@ function masterInit() {
'rr': SCHED_RR
}[process.env.NODE_CLUSTER_SCHED_POLICY];
- if (util.isUndefined(schedulingPolicy)) {
+ if (schedulingPolicy === undefined) {
// FIXME Round-robin doesn't perform well on Windows right now due to the
// way IOCP is wired up. Bert is going to fix that, eventually.
schedulingPolicy = (process.platform === 'win32') ? SCHED_NONE : SCHED_RR;
@@ -438,7 +438,7 @@ function masterInit() {
message.fd];
var key = args.join(':');
var handle = handles[key];
- if (util.isUndefined(handle)) {
+ if (handle === undefined) {
var constructor = RoundRobinHandle;
// UDP is exempt from round-robin connection balancing for what should
// be obvious reasons: it's connectionless. There is nothing to send to
@@ -562,7 +562,7 @@ function workerInit() {
delete handles[key];
return close.apply(this, arguments);
};
- assert(util.isUndefined(handles[key]));
+ assert(handles[key] === undefined);
handles[key] = handle;
cb(message.errno, handle);
}
@@ -586,7 +586,7 @@ function workerInit() {
// the ack by the master process in which we can still receive handles.
// onconnection() below handles that by sending those handles back to
// the master.
- if (util.isUndefined(key)) return;
+ if (key === undefined) return;
send({ act: 'close', key: key });
delete handles[key];
key = undefined;
@@ -607,7 +607,7 @@ function workerInit() {
if (message.sockname) {
handle.getsockname = getsockname; // TCP handles only.
}
- assert(util.isUndefined(handles[key]));
+ assert(handles[key] === undefined);
handles[key] = handle;
cb(0, handle);
}
@@ -616,7 +616,7 @@ function workerInit() {
function onconnection(message, handle) {
var key = message.key;
var server = handles[key];
- var accepted = !util.isUndefined(server);
+ var accepted = server !== undefined;
send({ ack: message.seq, accepted: accepted });
if (accepted) server.onconnection(0, handle);
}
@@ -664,7 +664,7 @@ function internal(worker, cb) {
return function(message, handle) {
if (message.cmd !== 'NODE_CLUSTER') return;
var fn = cb;
- if (!util.isUndefined(message.ack)) {
+ if (message.ack !== undefined) {
fn = callbacks[message.ack];
delete callbacks[message.ack];
}