mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Improve performance of raw tag editor
The detection whether `_entityIDs ` includes a relation is performed many times inside a loop. Instead this should be done only once (lazy).
This commit is contained in:
@@ -215,6 +215,7 @@ export function uiSectionRawTagEditor(id, context) {
|
||||
.merge(itemsEnter)
|
||||
.sort(function(a, b) { return a.index - b.index; });
|
||||
|
||||
var includesRelation = null;
|
||||
items
|
||||
.each(function(d) {
|
||||
var row = d3_select(this);
|
||||
@@ -230,10 +231,12 @@ export function uiSectionRawTagEditor(id, context) {
|
||||
if (typeof d.value !== 'string') {
|
||||
reference = uiTagReference({ key: d.key }, context);
|
||||
} else {
|
||||
var isRelation = _entityIDs && _entityIDs.some(function(entityID) {
|
||||
return context.entity(entityID).type === 'relation';
|
||||
});
|
||||
if (isRelation && d.key === 'type') {
|
||||
if (includesRelation === null) {
|
||||
includesRelation = _entityIDs && _entityIDs.some(function(entityID) {
|
||||
return context.entity(entityID).type === 'relation';
|
||||
});
|
||||
}
|
||||
if (includesRelation && d.key === 'type') {
|
||||
reference = uiTagReference({ rtype: d.value }, context);
|
||||
} else {
|
||||
reference = uiTagReference({ key: d.key, value: d.value }, context);
|
||||
|
||||
Reference in New Issue
Block a user