Skip to content

Commit

Permalink
Do not use a variable for looking up data.
Browse files Browse the repository at this point in the history
Using a variable for the lookup causes a major performance issue, resulting in diffing times of up to 3x longer.
  • Loading branch information
Sepand Parhami committed Sep 23, 2016
1 parent dd9677a commit ac03c59
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/node_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
import { createMap } from './util';


/**
* The property name where we store Incremental DOM data.
*/
const DATA_PROP = '__incrementalDOMData';


/**
* Keeps track of information needed to perform diffs for a given DOM node.
* @param {!string} nodeName
Expand Down Expand Up @@ -111,7 +105,7 @@ function NodeData(nodeName, key, typeId) {
*/
const initData = function(node, nodeName, key, typeId) {
const data = new NodeData(nodeName, key, typeId);
node[DATA_PROP] = data;
node['__incrementalDOMData'] = data;
return data;
};

Expand All @@ -124,7 +118,7 @@ const initData = function(node, nodeName, key, typeId) {
*/
const getData = function(node) {
importNode(node);
return node[DATA_PROP];
return node['__incrementalDOMData'];
};


Expand All @@ -134,7 +128,7 @@ const getData = function(node) {
* @param {?Node} node The Node to import.
*/
const importNode = function(node) {
if (node[DATA_PROP]) {
if (node['__incrementalDOMData']) {
return;
}

Expand Down

0 comments on commit ac03c59

Please sign in to comment.