Don't call childNodes unless necessary (avoid extra _childNodes caching)

`hasHiddenConnections` was calling it for all features, inluding points and
vertices, causing _childNodes to have a lot of unnecessary keys added to it.
This commit is contained in:
Bryan Housel
2015-12-22 12:03:08 -05:00
parent 14c618c3a8
commit 226b73fd48
2 changed files with 5 additions and 7 deletions

View File

@@ -81,14 +81,12 @@ iD.Graph.prototype = {
},
childNodes: function(entity) {
if (this._childNodes[entity.id])
return this._childNodes[entity.id];
if (this._childNodes[entity.id]) return this._childNodes[entity.id];
if (!entity.nodes) return [];
var nodes = [];
if (entity.nodes) {
for (var i = 0; i < entity.nodes.length; i++) {
nodes[i] = this.entity(entity.nodes[i]);
}
for (var i = 0; i < entity.nodes.length; i++) {
nodes[i] = this.entity(entity.nodes[i]);
}
if (iD.debug) Object.freeze(nodes);

View File

@@ -378,7 +378,7 @@ iD.Features = function(context) {
childNodes = [resolver.entity(entity.edge[0]), resolver.entity(entity.edge[1])];
connections = [];
} else {
childNodes = resolver.childNodes(entity);
childNodes = entity.nodes ? resolver.childNodes(entity) : [];
connections = features.getParents(entity, resolver, entity.geometry(resolver));
}