diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-03-18 16:54:54 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-03-18 16:54:54 +0100 |
commit | c913c6b179973a310cb6c4fbbfc4adefad50f6e0 (patch) | |
tree | 8f059bede8f49dac08b68109e2ee8ddd07cd592e | |
parent | 308737dac08a5fe9ae7e8c290939e57261c4a081 (diff) |
db/manager: optimize database modifications
Add only tags that are not present on the message, remove only tags
that are present.
Otherwise the no-op modification results in an actual db write, even
though nothing changes.
-rw-r--r-- | alot/db/manager.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/alot/db/manager.py b/alot/db/manager.py index 148cfe2a..efd70e70 100644 --- a/alot/db/manager.py +++ b/alot/db/manager.py @@ -60,12 +60,14 @@ class _DBWriteList: def _do_tag_add(self, db, tags, query): for msg in db.messages(query): msg_tags = msg.tags - msg_tags |= tags + op_tags = tags - msg_tags + msg_tags |= op_tags def _do_tag_remove(self, db, tags, query): for msg in db.messages(query): msg_tags = msg.tags - msg_tags -= tags + op_tags = tags & msg_tags + msg_tags -= op_tags def _do_tag_set(self, db, tags, query): for msg in db.messages(query): |