migaku-official / Migaku-Dictionary-Addon

Migaku Dictionary allows users to lookup word definitions, export definitions to their cards in real-time, hear word audio and see word frequency, etc. If you have an issue please report it in the "Issues" tab. Reponses to issues can be slow on GitHub, for faster support consider joining our Discord server through our Patreon page.
GNU General Public License v3.0
64 stars 24 forks source link

Speed up "If Empty" definition exports #49

Open Jefftree opened 3 years ago

Jefftree commented 3 years ago

Type:

Environment:

I'm going to open a PR to resolve the issue:

Description:

A common use case is incremental generation (eg: target field updated by Morphman) of definitions, where most definitions are already filled and only a small subset of cards need their definitions generated. Currently, Generating all definitions and only picking a small subset is a bit wasteful and is very slow in a deck with a lot of definitions already present. Can we optimize to skip the slow export lines

https://github.com/migaku-official/Migaku-Dictionary-Addon/blob/master/src/main.py#L964-L973

if note[dest] isn't empty when "If Empty" is selected? I can open a PR to fix this.