[sword-devel] Performance of getting a module's book list

Tobias Klein contact at tklein.info
Thu May 13 05:33:35 EDT 2021

Hi all,

I am wondering whether it is possible to optimize the performance for getting a module’s book list.

The function I am currently using looks like this:

        vector<string> bookList;
        string currentBookName = "";
        VerseKey *vk = (VerseKey *)module->getKey();

        for ((*vk) = TOP; !vk->popError(); vk->setBook(vk->getBook()+1)) {
            if (module->hasEntry(vk)) {
                currentBookName = vk->getOSISBookName();

In my node-sword-interface JavaScript world the wrapped function returns in a time between 10-15ms depending on the module.

When calling this once for the currently used Bible module … that’s fine.
But I now have a use case where I need to retrieve the book lists of all installed modules at once. In Ezra Bible App, the user has a possibility to switch the Bible module for the currently opened text.
In the respective selection box I would like to disable all Bible modules that do not contain the currently opened book. This could be the case for NT only, OT only or other modules of that sort.
In order to implement this dynamic disabling/enabling logic I need the book lists of all available SWORD modules at once. And suddenly we are looking at 200+ ms for the above mentioned function executed for let’s say 15 modules.

I am testing on a Mac mini to get performance figures for a lower end machine …

Now, having said all that … is there a way of optimizing the performance of the function above? Or have I overlooked something and need to approach this use case differently?

Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://crosswire.org/pipermail/sword-devel/attachments/20210513/78465bf1/attachment.html>

More information about the sword-devel mailing list