mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +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:
parent
397d67ff3d
commit
279a0e5371
1 changed files with 1 additions and 4 deletions
|
@ -9,14 +9,12 @@ JX.install('AphlictListenerList', {
|
||||||
members: {
|
members: {
|
||||||
_listeners: null,
|
_listeners: null,
|
||||||
_nextID: 0,
|
_nextID: 0,
|
||||||
_activeListenerCount: 0,
|
|
||||||
_totalListenerCount: 0,
|
_totalListenerCount: 0,
|
||||||
|
|
||||||
addListener: function(socket) {
|
addListener: function(socket) {
|
||||||
var listener = new JX.AphlictListener(this._generateNextID(), socket);
|
var listener = new JX.AphlictListener(this._generateNextID(), socket);
|
||||||
|
|
||||||
this._listeners[listener.getID()] = listener;
|
this._listeners[listener.getID()] = listener;
|
||||||
this._activeListenerCount++;
|
|
||||||
this._totalListenerCount++;
|
this._totalListenerCount++;
|
||||||
|
|
||||||
return listener;
|
return listener;
|
||||||
|
@ -26,7 +24,6 @@ JX.install('AphlictListenerList', {
|
||||||
var id = listener.getID();
|
var id = listener.getID();
|
||||||
if (id in this._listeners) {
|
if (id in this._listeners) {
|
||||||
delete this._listeners[id];
|
delete this._listeners[id];
|
||||||
this._activeListenerCount--;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -42,7 +39,7 @@ JX.install('AphlictListenerList', {
|
||||||
},
|
},
|
||||||
|
|
||||||
getActiveListenerCount: function() {
|
getActiveListenerCount: function() {
|
||||||
return this._activeListenerCount;
|
return Object.keys(this._listeners).length;
|
||||||
},
|
},
|
||||||
|
|
||||||
getTotalListenerCount: function() {
|
getTotalListenerCount: function() {
|
||||||
|
|
Loading…
Reference in a new issue