Avoid lastProps[key] lookup in initial render
This makes both Firefox and IE 15-20% faster in initial render (!!). On my PE benchmark, createElement is now on par with HTML in Firefox and faster in IE11 (before, it was slower).
Ben Alpert committed
Oct 24, 2015 at 12:19 UTC
22a240fd39b893982cc397ea8b8bcb78eb31158f
1 file changed
+4
-4
src/renderers/dom/shared/ReactDOMComponent.js
+4
-4
@@ -665,7 +665,7 @@ ReactDOMComponent.Mixin = {
665
DOMPropertyOperations.setAttributeForID(el, this._rootNodeID);
666
// Populate node cache
667
ReactMount.getID(el);
668
- this._updateDOMProperties({}, props, transaction);
668
+ this._updateDOMProperties(null, props, transaction);
669
var lazyTree = DOMLazyTree(el);
670
this._createInitialChildren(transaction, props, context, lazyTree);
671
mountImage = lazyTree;
@@ -964,9 +964,9 @@ ReactDOMComponent.Mixin = {
964
}
965
for (propKey in nextProps) {
966
var nextProp = nextProps[propKey];
967
- var lastProp = propKey === STYLE ?
968
- this._previousStyleCopy :
969
- lastProps[propKey];
967
+ var lastProp =
968
+ propKey === STYLE ? this._previousStyleCopy :
969
+ lastProps != null ? lastProps[propKey] : undefined;
970
if (!nextProps.hasOwnProperty(propKey) ||
971
nextProp === lastProp ||
972
nextProp == null && lastProp == null) {