Optimize difference

This commit is contained in:
Tom MacWright
2013-01-08 15:33:29 -05:00
parent 2f8454e50e
commit 4347b134de
+7 -5
View File
@@ -107,19 +107,21 @@ iD.Graph.prototype = {
},
difference: function (graph) {
var result = [];
var result = [], entity, id;
_.each(this.entities, function(entity, id) {
for (id in this.entities) {
entity = this.entities[id];
if (entity !== graph.entities[id]) {
result.push(id);
}
});
}
_.each(graph.entities, function(entity, id) {
for (id in graph.entities) {
entity = graph.entities[id];
if (entity && !this.entities.hasOwnProperty(id)) {
result.push(id);
}
}, this);
}
return result.sort();
},