From b29fd508c77f90bc41ffd3ad4c3fce3d0cba608e Mon Sep 17 00:00:00 2001 From: Arthur-Milchior Date: Sun, 20 Jan 2019 15:40:23 +0100 Subject: [PATCH] moveTemplate slightly quicker When a template is moved, only move the ord of cards whose position did change. --- anki/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/anki/models.py b/anki/models.py index 38e08e1b8..478b371c0 100644 --- a/anki/models.py +++ b/anki/models.py @@ -397,7 +397,10 @@ update cards set ord = ord - 1, usn = ?, mod = ? # generate change map map = [] for t in m['tmpls']: - map.append("when ord = %d then %d" % (oldidxs[id(t)], t['ord'])) + oldidx = oldidxs[id(t)] + newidx = t['ord'] + if oldidx != newidx: + map.append("when ord = %d then %d" % (oldidx, newidx)) # apply self.save(m) self.col.db.execute("""