Skip to content
Browse files

changing to regular for loop

  • Loading branch information...
1 parent 785c531 commit 93d66c87e254d16618504919a0b9a87996a53a61 @3rd-Eden committed
Showing with 9 additions and 5 deletions.
  1. +9 −5 lib/connectionpool.js
View
14 lib/connectionpool.js
@@ -299,14 +299,18 @@ Manager.prototype.free = function free(keep, hard) {
var saved = 0
, self = this;
- this.pool.forEach(function freewilly(connection) {
- var probability = self.isAvailable(connection);
+ for (var i = 0, length = this.pool.length; i < length; i++) {
+ var connection = this.pool[i];
+ var probability = this.isAvailable(connection);
// this is still a healthy connection, so try we probably just want to keep it
- if (keep && saved < keep && probability === 100) return saved++;
+ if (keep && saved < keep && probability === 100) {
+ saved++;
+ continue;
+ }
- self.release(connection, hard);
- });
+ this.release(connection, hard);
+ }
// see how much connections are still available
this.emit('free', saved, this.pool.length);

0 comments on commit 93d66c8

Please sign in to comment.
Something went wrong with that request. Please try again.