diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-03-29 06:00:58 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-03-29 06:00:58 +0300 |
commit | 1973007f7fa336774d20d7a0578894832c25d00b (patch) | |
tree | 9ec3c25be3099f27c5923c445709f87b7fe91f69 /lib/tcp-pool.js | |
parent | b6ac41ae3b55153ad8faedfee53c421ae2a75d53 (diff) |
Replace expensive arr.splice() with unordered-array-remove in hot code
For https://github.com/feross/webtorrent-desktop/issues/256
Diffstat (limited to 'lib/tcp-pool.js')
-rw-r--r-- | lib/tcp-pool.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/tcp-pool.js b/lib/tcp-pool.js index 02148e3..bf75ebe 100644 --- a/lib/tcp-pool.js +++ b/lib/tcp-pool.js @@ -1,5 +1,6 @@ module.exports = TCPPool +var arrayRemove = require('unordered-array-remove') var debug = require('debug')('webtorrent:tcp-pool') var net = require('net') // browser exclude @@ -198,7 +199,7 @@ TCPPool.prototype._onConnection = function (conn) { conn.once('close', removePendingConn) function removePendingConn () { - self.pendingConns.splice(self.pendingConns.indexOf(conn)) + arrayRemove(self.pendingConns, self.pendingConns.indexOf(conn)) } var peer = Peer.createTCPIncomingPeer(conn) |