Improve performance a lot
- Smarter use of buffers
- Read and write to file instead of standard input and output
Benchmarks on my computer on https://github.com/BoboTiG/ebook-reader-dict/releases/tag/fr
Original code: ⩾9s This code: ⩾2s
Every change has been tested before/after with hyperfine and I checked that the produced files are exactly the same for several (2) dictionaries.
Ideally, I would like to be able to bypass dictfmt in the Plato script and produce directly a DICT.org file but I have trouble finding a good documentation about the format.
We could even go further and not have to convert from StarDict by adding support for this format in the dictionary module. You might also be interested in this pull request.
Sadly, I don’t think I will have time in the foreseeable future to work on that. Still, was fun to work on and an immediate improvement over what’s already existing.
I opened an issue on ebook-reader-dict’s repo so that they could provide directly the correct format for Plato.
I’m not sure if you’d be willing to merge this? I could make the appropriate change to the convert-dictionaries.sh script of Plato (since it’s a relatively minor change). It would improve the speed of the process with very little work.