mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
optimization: avoid use of Map in hot path in favor of array with duplicates.
This commit is contained in:
@@ -46,7 +46,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
/**
|
||||
* Ensures that the model has an own-property map of effects for the given type.
|
||||
* The model may be a prototype or an instance.
|
||||
*
|
||||
*
|
||||
* Property effects are stored as arrays of effects by property in a map,
|
||||
* by named type on the model. e.g.
|
||||
*
|
||||
@@ -58,7 +58,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* If the model does not yet have an effect map for the type, one is created
|
||||
* and returned. If it does, but it is not an own property (i.e. the
|
||||
* prototype had effects), the the map is deeply cloned and the copy is
|
||||
* set on the model and returned, ready for new effects to be added.
|
||||
* set on the model and returned, ready for new effects to be added.
|
||||
*
|
||||
* @param {Object} model Prototype or instance
|
||||
* @param {string} type Property effect type
|
||||
@@ -214,7 +214,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches {property}-changed events with path information in the detail
|
||||
* Dispatches {property}-changed events with path information in the detail
|
||||
* object to indicate a sub-path of the property was changed.
|
||||
*
|
||||
* @param {Element} inst The element from which to fire the event
|
||||
@@ -297,7 +297,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* @param {Event} e Notification event (e.g. '<property>-changed')
|
||||
* @param {Object} inst Host element instance handling the notification event
|
||||
* @param {string} property Child element property that was bound
|
||||
* @param {string} path Host property/path that was bound
|
||||
* @param {string} path Host property/path that was bound
|
||||
* @param {boolean} negate Whether the binding was negated
|
||||
* @private
|
||||
*/
|
||||
@@ -430,7 +430,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* @param {Object} computedProps Bag of properties newly computed this turn
|
||||
* via "computed" effects; any linked paths generated via this method
|
||||
* will be added both to the set of `changedProps` as well as to the
|
||||
* set of `computedProps`; this is because the `fromAbove: true` case will
|
||||
* set of `computedProps`; this is because the `fromAbove: true` case will
|
||||
* notify only from the `computedProps` bag.
|
||||
* @private
|
||||
*/
|
||||
@@ -670,7 +670,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* - Memoizes the root property for path bindings
|
||||
* - Recurses into nested templates and processes those templates and
|
||||
* extracts any host properties, which are set to the template's
|
||||
* `_content._hostProps`
|
||||
* `_content._hostProps`
|
||||
* - Adds bindings from the host to <template> elements for any nested
|
||||
* template's lexically bound "host properties"; template handling
|
||||
* elements can then add accessors to the template for these properties
|
||||
@@ -1052,7 +1052,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
*
|
||||
* The `path` and `value` arguments are used to fill in wildcard descriptor
|
||||
* when the method is being called as a result of a path notification.
|
||||
*
|
||||
*
|
||||
* @param {Object} data Instance data storage object to read properties from
|
||||
* @param {Array<Object>} args Array of argument metadata
|
||||
* @return {Array<*>} Array of argument values
|
||||
@@ -1096,7 +1096,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* Initializes `__dataCompoundStorage` local storage on a bound node with
|
||||
* initial literal data for compound bindings, and sets the joined
|
||||
* literal parts to the bound property.
|
||||
*
|
||||
*
|
||||
* When changes to compound parts occur, they are first set into the compound
|
||||
* storage array for that property, and then the array is joined to result in
|
||||
* the final value set to the property/attribute.
|
||||
@@ -1137,7 +1137,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// data api
|
||||
|
||||
/**
|
||||
* Sends array splice notifications (`.splices` and `.length`)
|
||||
* Sends array splice notifications (`.splices` and `.length`)
|
||||
*
|
||||
* Note: this implementation only accepts normalized paths
|
||||
*
|
||||
@@ -1369,7 +1369,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
*
|
||||
* If `path` is an unmanaged property (property without an accessor)
|
||||
* or a path, sets the value at that path.
|
||||
*
|
||||
*
|
||||
* `path` can be a path string or array of path parts as accepted by the
|
||||
* public API.
|
||||
*
|
||||
@@ -1406,7 +1406,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
if (!super._shouldPropertyChange(path, value, old)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasEffect) {
|
||||
return path;
|
||||
}
|
||||
@@ -1472,7 +1472,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
/**
|
||||
* Overrides default PropertyAccessors implementation to pull the value
|
||||
* to dirty check against from the `__dataTemp` cache (rather than the
|
||||
* to dirty check against from the `__dataTemp` cache (rather than the
|
||||
* normal `__data` cache) for Objects. Since the temp cache is cleared
|
||||
* at the end of a turn, this implementation allows side-effects of deep
|
||||
* object changes to be processed by re-setting the same object (using
|
||||
@@ -1492,12 +1492,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides PropertyAccessor's default async queuing of
|
||||
* Overrides PropertyAccessor's default async queuing of
|
||||
* `_propertiesChanged`: if `__dataInitialized` is false (has not yet been
|
||||
* manually flushed), the function no-ops; otherwise flushes
|
||||
* `_propertiesChanged` synchronously.
|
||||
*
|
||||
* Subclasses may set `this._asyncEffects = true` to cause
|
||||
* Subclasses may set `this._asyncEffects = true` to cause
|
||||
* `_propertiesChanged` to be flushed asynchronously.
|
||||
*
|
||||
* @override
|
||||
@@ -1521,9 +1521,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* @protected
|
||||
*/
|
||||
_enqueueClient(client) {
|
||||
this.__dataPendingClients = this.__dataPendingClients || new Map();
|
||||
this.__dataPendingClients = this.__dataPendingClients || [];
|
||||
if (client !== this) {
|
||||
this.__dataPendingClients.set(client, true);
|
||||
this.__dataPendingClients.push(client);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1538,12 +1538,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
let clients = this.__dataPendingClients;
|
||||
if (clients) {
|
||||
this.__dataPendingClients = null;
|
||||
clients.forEach((v, client) => {
|
||||
for (let i=0; i < clients.length; i++) {
|
||||
let client = clients[i];
|
||||
// TODO(kschaaf): more explicit check?
|
||||
if (client._flushProperties) {
|
||||
if (!client.__dataInitialized || client.__dataPending) {
|
||||
client._flushProperties(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1567,7 +1568,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
this._invalidateProperties();
|
||||
}
|
||||
/**
|
||||
* Overrides PropertyAccessor's default async queuing of
|
||||
* Overrides PropertyAccessor's default async queuing of
|
||||
* `_propertiesChanged`, to instead synchronously flush
|
||||
* `_propertiesChanged` unless the `this._asyncEffects` property is true.
|
||||
*
|
||||
@@ -1627,7 +1628,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* listeners, and the `this.$` map of `id`'s to nodes. A document fragment
|
||||
* is returned containing the stamped DOM, ready for insertion into the
|
||||
* DOM.
|
||||
*
|
||||
*
|
||||
* Note that for host data to be bound into the stamped DOM, the template
|
||||
* must have been previously bound to the prototype via a call to
|
||||
* `_bindTemplate`, which performs one-time template binding work.
|
||||
@@ -1801,7 +1802,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
if ((path = this._setPathOrUnmanagedProperty(path, value))) {
|
||||
this._setProperty(path, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1972,7 +1973,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* Creates a read-only accessor for the given property.
|
||||
*
|
||||
* To set the property, use the protected `_setProperty` API.
|
||||
* To create a custom protected setter (e.g. `_setMyProp()` for
|
||||
* To create a custom protected setter (e.g. `_setMyProp()` for
|
||||
* property `myProp`), pass `true` for `protectedSetter`.
|
||||
*
|
||||
* Note, if the property will have other property effects, this method
|
||||
|
||||
Reference in New Issue
Block a user