Skip to content

Commit

Permalink
feat(JitsiParticipant) use a Map for properties, rather than an object
Browse files Browse the repository at this point in the history
See https://www.zhenghao.io/posts/object-vs-map

Since these objects will change with reasonable requency, we'll create
many shapes and consume more memory than a Map.
  • Loading branch information
saghul committed Oct 22, 2024
1 parent 6782e6c commit a72936d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions JitsiParticipant.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class JitsiParticipant {
this._status = status;
this._hidden = hidden;
this._statsID = statsID;
this._properties = {};
this._properties = new Map();
this._identity = identity;
this._isReplacing = isReplacing;
this._isReplaced = isReplaced;
Expand Down Expand Up @@ -171,7 +171,7 @@ export default class JitsiParticipant {
* Gets the value of a property of this participant.
*/
getProperty(name) {
return this._properties[name];
return this._properties.get(name);
}

/**
Expand Down Expand Up @@ -347,10 +347,10 @@ export default class JitsiParticipant {
* @value the value to set.
*/
setProperty(name, value) {
const oldValue = this._properties[name];
const oldValue = this._properties.get(name);

if (value !== oldValue) {
this._properties[name] = value;
this._properties.set(name, value);
this._conference.eventEmitter.emit(
JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
this,
Expand Down

0 comments on commit a72936d

Please sign in to comment.