mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Improve performance somewhat in some scenarios (re: #7656)
This commit is contained in:
@@ -57,8 +57,8 @@ export function coreDifference(base, head) {
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys(head.entities).forEach(checkEntityID);
|
||||
Object.keys(base.entities).forEach(checkEntityID);
|
||||
for (var id in head.entities) checkEntityID(id);
|
||||
for (var id in base.entities) checkEntityID(id);
|
||||
|
||||
|
||||
_diff.length = function length() {
|
||||
|
||||
@@ -68,9 +68,10 @@ export function coreTree(head) {
|
||||
var diff = coreDifference(head, graph);
|
||||
var changed = diff.didChange;
|
||||
|
||||
head = graph;
|
||||
|
||||
if (changed.addition || changed.deletion || changed.geometry) {
|
||||
var insertions = {};
|
||||
head = graph;
|
||||
|
||||
if (changed.deletion) {
|
||||
diff.deleted().forEach(function(entity) {
|
||||
|
||||
@@ -156,15 +156,12 @@ Object.assign(osmNode.prototype, {
|
||||
return resolver.transient(this, 'isConnected', function() {
|
||||
var parents = resolver.parentWays(this);
|
||||
|
||||
function isLine(entity) {
|
||||
return entity.geometry(resolver) === 'line' &&
|
||||
entity.hasInterestingTags();
|
||||
}
|
||||
|
||||
// vertex is connected to multiple parent lines
|
||||
if (parents.length > 1 && parents.some(isLine)) {
|
||||
return true;
|
||||
|
||||
if (parents.length > 1) {
|
||||
// vertex is connected to multiple parent ways
|
||||
for (var i in parents) {
|
||||
if (parents[i].geometry(resolver) === 'line' &&
|
||||
parents[i].hasInterestingTags()) return true;
|
||||
}
|
||||
} else if (parents.length === 1) {
|
||||
var way = parents[0];
|
||||
var nodes = way.nodes.slice();
|
||||
|
||||
@@ -26,18 +26,20 @@ export function svgPassiveVertex(node, graph, activeID) {
|
||||
|
||||
var parents = graph.parentWays(node);
|
||||
|
||||
for (var i = 0; i < parents.length; i++) {
|
||||
var nodes = parents[i].nodes;
|
||||
var isClosed = parents[i].isClosed();
|
||||
for (var j = 0; j < nodes.length; j++) { // find this vertex, look nearby
|
||||
var i, j, nodes, isClosed, ix1, ix2, ix3, ix4, max;
|
||||
|
||||
for (i = 0; i < parents.length; i++) {
|
||||
nodes = parents[i].nodes;
|
||||
isClosed = parents[i].isClosed();
|
||||
for (j = 0; j < nodes.length; j++) { // find this vertex, look nearby
|
||||
if (nodes[j] === node.id) {
|
||||
var ix1 = j - 2;
|
||||
var ix2 = j - 1;
|
||||
var ix3 = j + 1;
|
||||
var ix4 = j + 2;
|
||||
ix1 = j - 2;
|
||||
ix2 = j - 1;
|
||||
ix3 = j + 1;
|
||||
ix4 = j + 2;
|
||||
|
||||
if (isClosed) { // wraparound if needed
|
||||
var max = nodes.length - 1;
|
||||
max = nodes.length - 1;
|
||||
if (ix1 < 0) ix1 = max + ix1;
|
||||
if (ix2 < 0) ix2 = max + ix2;
|
||||
if (ix3 > max) ix3 = ix3 - max;
|
||||
|
||||
Reference in New Issue
Block a user