Skip to content

Commit

Permalink
Also cache rank node property
Browse files Browse the repository at this point in the history
  • Loading branch information
rndstr committed Jul 21, 2017
1 parent e2d5a2a commit bcd81aa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/app/scripts/charts/nodes-layout.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dagre from 'dagre';
import debug from 'debug';
import { fromJS, Map as makeMap, Set as ImmSet } from 'immutable';
import pick from 'lodash/pick';

import { NODE_BASE_SIZE, EDGE_WAYPOINTS_CAP } from '../constants/styles';
import { EDGE_ID_SEPARATOR } from '../constants/naming';
Expand Down Expand Up @@ -487,7 +488,10 @@ export function doLayout(immNodes, immEdges, opts) {

// cache results
cache.cachedLayout = layout;
cache.nodeCache = cache.nodeCache.merge(layout.nodes.map(n => fromJS({ x: n.get('x'), y: n.get('y') })));
// only cache layout-related properties
// NB: These properties must be immutable wrt a given node because properties of updated nodes
// will be overwritten with the cached values, see copyLayoutProperties()
cache.nodeCache = cache.nodeCache.merge(layout.nodes.map(n => pick(n.toJS(), ['x', 'y', 'rank'])));
cache.edgeCache = cache.edgeCache.merge(layout.edges);
}

Expand Down

0 comments on commit bcd81aa

Please sign in to comment.