From f42beee45c27dba9433d76217fb583b117fb5231 Mon Sep 17 00:00:00 2001 From: Matthias M <62722460+kleinerpirat@users.noreply.github.com> Date: Mon, 15 Nov 2021 12:02:17 +0100 Subject: [PATCH] Initially load option at newIndex and remaining options on focus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Optimization for big notetypes: Should increase efficiency from O(n²) to O(n). Test on notetype with 500 templates shows significant improvement in load time (~10s down to ~1s). --- ts/change-notetype/MapperRow.svelte | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ts/change-notetype/MapperRow.svelte b/ts/change-notetype/MapperRow.svelte index 55d0f32b9..a0563fa54 100644 --- a/ts/change-notetype/MapperRow.svelte +++ b/ts/change-notetype/MapperRow.svelte @@ -21,29 +21,34 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html current = oldNames[newIndex] || tr.changeNotetypeNothing(); } - function onChange(evt: Event) { - const oldIdx = parseInt((evt.target as HTMLSelectElement).value, 10); - state.setOldIndex(ctx, newIndex, oldIdx); - } - // optimization for big notetypes let active: boolean = false; function activate(evt: Event) { active = true; } + + function onChange(evt: Event) { + const oldIdx = parseInt((evt.target as HTMLSelectElement).value, 10); + state.setOldIndex(ctx, newIndex, oldIdx); + }