Permalink
Browse files

remove extra nextTicks in collection methods

  • Loading branch information...
aheckmann committed Jul 13, 2012
1 parent 92eed04 commit de5be4b7ce8145947d8b0ea30dbdf9f13773669a
Showing with 21 additions and 23 deletions.
  1. +4 −3 lib/connection.js
  2. +17 −20 lib/drivers/node-mongodb-native/collection.js
View
@@ -209,11 +209,12 @@ Connection.prototype.open = function (host, database, port, options, callback) {
self.emit("error", err);
}
self.readyState = STATES.disconnected;
- } else {
- self.onOpen();
+ callback(err);
+ return;
}
- callback(err || null);
+ self.onOpen();
+ callback(err);
});
return this;
@@ -122,28 +122,25 @@ for (var i in NativeCollection.prototype)
var collection = this.collection
, args = arguments
- , self = this;
-
- process.nextTick(function(){
- var debug = self.conn.base.options.debug;
-
- if (debug) {
- if ('function' === typeof debug) {
- debug.apply(debug
- , [self.name, i].concat(utils.args(args, 0, args.length-1)));
- } else {
- console.error('\x1B[0;36mMongoose:\x1B[0m %s.%s(%s) %s %s %s'
- , self.name
- , i
- , print(args[0])
- , print(args[1])
- , print(args[2])
- , print(args[3]))
- }
+ , self = this
+ , debug = self.conn.base.options.debug;
+
+ if (debug) {
+ if ('function' === typeof debug) {
+ debug.apply(debug
+ , [self.name, i].concat(utils.args(args, 0, args.length-1)));
+ } else {
+ console.error('\x1B[0;36mMongoose:\x1B[0m %s.%s(%s) %s %s %s'
+ , self.name
+ , i
+ , print(args[0])
+ , print(args[1])
+ , print(args[2])
+ , print(args[3]))
}
+ }
- collection[i].apply(collection, args);
- });
+ collection[i].apply(collection, args);
};
})(i);

0 comments on commit de5be4b

Please sign in to comment.