Skip to content

Commit 90c6936

Browse files
authored
Don't use object pool for initialOldData, and properly recycle tempObject (#5459)
Co-authored-by: Noeri Huisman <[email protected]>
1 parent f92ea27 commit 90c6936

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/core/a-entity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class AEntity extends ANode {
278278
/**
279279
* Initialize component.
280280
*
281-
* @param {string} attrName - Attribute name asociated to the component.
281+
* @param {string} attrName - Attribute name associated to the component.
282282
* @param {object} data - Component data
283283
* @param {boolean} isDependency - True if the component is a dependency.
284284
*/

src/core/component.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var upperCaseRegExp = new RegExp('[A-Z]+');
1919

2020
// Object pools by component, created upon registration.
2121
var objectPools = {};
22+
var emptyInitialOldData = Object.freeze({});
2223

2324
/**
2425
* Component class definition.
@@ -223,7 +224,7 @@ Component.prototype = {
223224
}
224225
utils.objectPool.clearObject(this.attrValue);
225226
this.attrValue = extendProperties(this.attrValue, newAttrValue, this.isObjectBased);
226-
utils.objectPool.clearObject(tempObject);
227+
this.objectPool.recycle(tempObject);
227228
},
228229

229230
/**
@@ -271,7 +272,7 @@ Component.prototype = {
271272
*
272273
* @param {string} attrValue - HTML attribute value.
273274
* If undefined, use the cached attribute value and continue updating properties.
274-
* @param {boolean} clobber - The previous component data is overwritten by the atrrValue.
275+
* @param {boolean} clobber - The previous component data is overwritten by the attrValue.
275276
*/
276277
updateProperties: function (attrValue, clobber) {
277278
var el = this.el;
@@ -324,9 +325,8 @@ Component.prototype = {
324325

325326
// For oldData, pass empty object to multiple-prop schemas or object single-prop schema.
326327
// Pass undefined to rest of types.
327-
initialOldData = this.isObjectBased ? this.objectPool.use() : undefined;
328+
initialOldData = this.isObjectBased ? emptyInitialOldData : undefined;
328329
this.update(initialOldData);
329-
if (this.isObjectBased) { this.objectPool.recycle(initialOldData); }
330330

331331
// Play the component if the entity is playing.
332332
if (el.isPlaying) { this.play(); }

0 commit comments

Comments
 (0)