1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32:39 +01:00

Don't explicitly keep track of _activeListenerCount in the Aphlict server.

Summary: The `_activeListenerCount` variable is overkill, we should be able to achieve the same result using `Object.keys(this._listeners).length`.

Test Plan:
Mucked around in a NodeJS shell.

```lang=js
> Object.keys({}).length
0
> Object.keys({foo: 'bar'}).length
1
> Object.keys({1: 'foo', 2: 'bar'}).length
2
```

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9554
This commit is contained in:
Joshua Spence 2014-06-16 05:20:00 +10:00
parent 397d67ff3d
commit 279a0e5371

View file

@ -9,14 +9,12 @@ JX.install('AphlictListenerList', {
members: {
_listeners: null,
_nextID: 0,
_activeListenerCount: 0,
_totalListenerCount: 0,
addListener: function(socket) {
var listener = new JX.AphlictListener(this._generateNextID(), socket);
this._listeners[listener.getID()] = listener;
this._activeListenerCount++;
this._totalListenerCount++;
return listener;
@ -26,7 +24,6 @@ JX.install('AphlictListenerList', {
var id = listener.getID();
if (id in this._listeners) {
delete this._listeners[id];
this._activeListenerCount--;
}
},
@ -42,7 +39,7 @@ JX.install('AphlictListenerList', {
},
getActiveListenerCount: function() {
return this._activeListenerCount;
return Object.keys(this._listeners).length;
},
getTotalListenerCount: function() {