From a72936d86427716e9500156ce05fe53b1a8ddca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 22 Oct 2024 11:21:35 +0200 Subject: [PATCH] feat(JitsiParticipant) use a Map for properties, rather than an object 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. --- JitsiParticipant.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/JitsiParticipant.js b/JitsiParticipant.js index 3b89f2af18..bc58167e27 100644 --- a/JitsiParticipant.js +++ b/JitsiParticipant.js @@ -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; @@ -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); } /** @@ -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,