<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I solved this by implementing a new helper method that simply checks for the presence of a specific book within a given module.<div class="">This faster than doing the look-up based on a complete book list.</div><div class=""><br class=""></div><div class=""><div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Menlo, Monaco, "Courier New", monospace; line-height: 18px; white-space: pre;" class=""><div class=""><span style="color: #569cd6;" class="">bool</span> <span style="color: #4ec9b0;" class="">ModuleHelper</span>::<span style="color: #dcdcaa;" class="">moduleHasBook</span>(<span style="color: #4ec9b0;" class="">sword</span>::<span style="color: #4ec9b0;" class="">SWModule</span><span style="color: #569cd6;" class="">*</span> <span style="color: #9cdcfe;" class="">module</span>, <span style="color: #4ec9b0;" class="">std</span>::<span style="color: #4ec9b0;" class="">string</span> <span style="color: #9cdcfe;" class="">bookCode</span>)</div><div class="">{</div><div class=""> <span style="color: #569cd6;" class="">bool</span> <span style="color: #9cdcfe;" class="">hasBook</span>;</div><div class=""> <span style="color: #4ec9b0;" class="">stringstream</span> <span style="color: #9cdcfe;" class="">key</span>;</div><div class=""> <span style="color: #9cdcfe;" class="">key</span> <span style="color: #dcdcaa;" class=""><<</span> <span style="color: #9cdcfe;" class="">bookCode</span>;</div><div class=""> <span style="color: #9cdcfe;" class="">key</span> <span style="color: #dcdcaa;" class=""><<</span> <span style="color: #ce9178;" class="">" 1:1"</span>;</div><br class=""><div class=""> <span style="color: #9cdcfe;" class="">module</span>-><span style="color: #dcdcaa;" class="">setKey</span>(<span style="color: #9cdcfe;" class="">key</span>.<span style="color: #dcdcaa;" class="">str</span>().<span style="color: #dcdcaa;" class="">c_str</span>());</div><div class=""> <span style="color: #9cdcfe;" class="">hasBook</span> = <span style="color: #9cdcfe;" class="">module</span>-><span style="color: #dcdcaa;" class="">hasEntry</span>(<span style="color: #9cdcfe;" class="">module</span>-><span style="color: #dcdcaa;" class="">getKey</span>());</div><div class=""> </div><div class=""> <span style="color: #c586c0;" class="">return</span> <span style="color: #9cdcfe;" class="">hasBook</span>;</div><div class="">}</div></div></div><div class=""><br class=""></div><div class="">Having 18 modules installed locally … calling this method for all 18 modules takes between 20-30 ms on the JavaScript side … and that’s sufficient :-).</div><div class=""><br class=""></div><div class="">Best regards,</div><div class="">Tobias</div><div class=""><br class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">Am 13.05.2021 um 11:33 schrieb Tobias Klein <<a href="mailto:contact@tklein.info" class="">contact@tklein.info</a>>:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">I am wondering whether it is possible to optimize the performance for getting a module’s book list.</div><div class=""><br class=""></div><div class="">The function I am currently using looks like this:</div><div class=""><br class=""></div><div class=""><div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Menlo, Monaco, "Courier New", monospace; line-height: 18px; white-space: pre;" class=""><div style="line-height: 18px;" class=""><div class=""> <span style="color: #4ec9b0;" class="">vector</span><<span style="color: #4ec9b0;" class="">string</span>> <span style="color: #9cdcfe;" class="">bookList</span>;</div><div class=""> <span style="color: #4ec9b0;" class="">string</span> <span style="color: #9cdcfe;" class="">currentBookName</span> = <span style="color: #ce9178;" class="">""</span>;</div><div class=""> <span style="color: #4ec9b0;" class="">VerseKey</span> *<span style="color: #9cdcfe;" class="">vk</span> = (<span style="color: #4ec9b0;" class="">VerseKey</span> *)<span style="color: #9cdcfe;" class="">module</span>-><span style="color: #dcdcaa;" class="">getKey</span>();</div><br class=""><div class=""> <span style="color: #c586c0;" class="">for</span> ((*<span style="color: #9cdcfe;" class="">vk</span>) <span style="color: #dcdcaa;" class="">=</span> <span style="color: #569cd6;" class="">TOP</span>; !<span style="color: #9cdcfe;" class="">vk</span>-><span style="color: #dcdcaa;" class="">popError</span>(); <span style="color: #9cdcfe;" class="">vk</span>-><span style="color: #dcdcaa;" class="">setBook</span>(<span style="color: #9cdcfe;" class="">vk</span>-><span style="color: #dcdcaa;" class="">getBook</span>()+<span style="color: #b5cea8;" class="">1</span>)) {</div><div class=""> <span style="color: #c586c0;" class="">if</span> (<span style="color: #9cdcfe;" class="">module</span>-><span style="color: #dcdcaa;" class="">hasEntry</span>(<span style="color: #9cdcfe;" class="">vk</span>)) {</div><div class=""> <span style="color: #9cdcfe;" class="">currentBookName</span> <span style="color: #dcdcaa;" class="">=</span> <span style="color: #9cdcfe;" class="">vk</span>-><span style="color: #dcdcaa;" class="">getOSISBookName</span>();</div><div class=""> <span style="color: #9cdcfe;" class="">bookList</span>.<span style="color: #dcdcaa;" class="">push_back</span>(<span style="color: #9cdcfe;" class="">currentBookName</span>);</div><div class=""> }</div><div class=""> }</div></div></div></div><div class=""><br class=""></div><div class="">In my node-sword-interface JavaScript world the wrapped function returns in a time between 10-15ms depending on the module.</div><div class=""><br class=""></div><div class="">When calling this once for the currently used Bible module … that’s fine.</div><div class="">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.</div><div class="">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.</div><div class="">In order to implement this dynamic disabling/enabling logic I need the book lists of all available SWORD modules <u class="">at once</u>. And suddenly we are looking at 200+ ms for the above mentioned function executed for let’s say 15 modules.</div><div class=""><br class=""></div><div class="">I am testing on a Mac mini to get performance figures for a lower end machine …</div><div class=""><br class=""></div><div class="">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?</div><div class=""><br class=""></div><div class="">Best regards,</div><div class="">Tobias</div></div>_______________________________________________<br class="">sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org" class="">sword-devel@crosswire.org</a><br class=""><a href="http://crosswire.org/mailman/listinfo/sword-devel" class="">http://crosswire.org/mailman/listinfo/sword-devel</a><br class="">Instructions to unsubscribe/change your settings at above page</div></blockquote></div><br class=""></div></div></body></html>