Avoid initializing properties unnecessarily (perf benefit).

Due to the megamorphic nature of code in base classes with many extensions such as these, we saw these initializations _costing_ more than helping with "object shaping."
This commit is contained in:
Kevin Schaaf
2018-11-28 17:31:56 -08:00
parent 1b5849e5f4
commit 4228d666bc
3 changed files with 32 additions and 16 deletions
+1 -1
View File
@@ -136,7 +136,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
constructor() {
super();
/** @type {boolean} */
this.__autoDirOptOut = false;
this.__autoDirOptOut;
}
/**
+14 -7
View File
@@ -155,14 +155,21 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
constructor() {
super();
this.__dataEnabled = false;
this.__dataReady = false;
this.__dataInvalid = false;
/** @type {boolean} */
this.__dataEnabled;
/** @type {boolean} */
this.__dataReady;
/** @type {boolean} */
this.__dataInvalid;
this.__data = {};
this.__dataPending = null;
this.__dataOld = null;
this.__dataInstanceProps = null;
this.__serializing = false;
/** @type {Object} */
this.__dataPending;
/** @type {Object} */
this.__dataOld;
/** @type {Object} */
this.__dataInstanceProps;
/** @type {boolean} */
this.__serializing;
this._initializeProperties();
}
+17 -8
View File
@@ -1145,16 +1145,25 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_initializeProperties() {
super._initializeProperties();
hostStack.registerHost(this);
this.__dataClientsReady = false;
this.__dataPendingClients = null;
this.__dataToNotify = null;
this.__dataLinkedPaths = null;
this.__dataHasPaths = false;
/** @type {boolean} */
this.__dataClientsReady;
/** @type {Array<PropertyEffects>} */
this.__dataPendingClients;
/** @type {Object} */
this.__dataToNotify;
/** @type {Object} */
this.__dataLinkedPaths;
/** @type {boolean} */
this.__dataHasPaths;
// May be set on instance prior to upgrade
this.__dataCompoundStorage = this.__dataCompoundStorage || null;
this.__dataHost = this.__dataHost || null;
/** @type {Array<string>} */
this.__dataCompoundStorage;
/** @type {PropertyEffects} */
this.__dataHost;
/** @type {Object} */
this.__dataTemp = {};
this.__dataClientsInitialized = false;
/** @type {boolean} */
this.__dataClientsInitialized;
}
/**