mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-03 21:48:03 +02:00
Small parentWays, parentRelations perf improvements
This commit is contained in:
+10
-7
@@ -24,6 +24,7 @@ iD.Graph = function(other, mutable) {
|
||||
|
||||
this.transients = {};
|
||||
this._childNodes = {};
|
||||
this.getEntity = _.bind(this.entity, this);
|
||||
|
||||
if (!mutable) {
|
||||
this.freeze();
|
||||
@@ -48,19 +49,21 @@ iD.Graph.prototype = {
|
||||
},
|
||||
|
||||
parentWays: function(entity) {
|
||||
return _.map(this._parentWays[entity.id], _.bind(this.entity, this));
|
||||
return _.map(this._parentWays[entity.id], this.getEntity);
|
||||
},
|
||||
|
||||
isPoi: function(entity) {
|
||||
return this.parentWays(entity).length === 0;
|
||||
var parentWays = this._parentWays[entity.id];
|
||||
return !parentWays || parentWays.length === 0;
|
||||
},
|
||||
|
||||
isShared: function(entity) {
|
||||
var parentWays = this._parentWays[entity.id];
|
||||
return parentWays && parentWays.length > 1;
|
||||
},
|
||||
|
||||
parentRelations: function(entity) {
|
||||
return _.map(this._parentRels[entity.id], _.bind(this.entity, this));
|
||||
var ent, id, parents;
|
||||
|
||||
|
||||
return this._parentRels[entity.id] || [];
|
||||
return _.map(this._parentRels[entity.id], this.getEntity);
|
||||
},
|
||||
|
||||
childNodes: function(entity) {
|
||||
|
||||
@@ -64,7 +64,7 @@ iD.Map = function() {
|
||||
for (var i = 0; i < parents.length; i++) {
|
||||
var parent = parents[i];
|
||||
if (only[parent.id] === undefined) {
|
||||
only[parent.id] = graph.entity(parent.id);
|
||||
only[parent.id] = parent;
|
||||
addParents(graph.parentRelations(parent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ iD.svg.Vertices = function(projection) {
|
||||
groups.attr('transform', iD.svg.PointTransform(projection))
|
||||
.call(iD.svg.TagClasses())
|
||||
.call(iD.svg.MemberClasses(graph))
|
||||
.classed('shared', function(entity) { return graph.parentWays(entity).length > 1; });
|
||||
.classed('shared', function(entity) { return graph.isShared(entity); });
|
||||
|
||||
// Selecting the following implicitly
|
||||
// sets the data (vertix entity) on the elements
|
||||
|
||||
Reference in New Issue
Block a user