Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2016-03-29 06:00:58 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-03-29 06:00:58 +0300
commit1973007f7fa336774d20d7a0578894832c25d00b (patch)
tree9ec3c25be3099f27c5923c445709f87b7fe91f69 /lib/tcp-pool.js
parentb6ac41ae3b55153ad8faedfee53c421ae2a75d53 (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.js3
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)