<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Troy,</p>
<p>Thanks once more for highlighting the code smells as you did! :)<br>
<br>
In node-sword-interface, I have now implemented two new helper
methods <a moz-do-not-send="true"
href="https://github.com/ezra-project/node-sword-interface/blob/ba3a0347fbe9a19cec5bd3daac080c5325dc7393/src/sword_backend/module_helper.cpp#L92">getBookChapterCount</a>
and <a moz-do-not-send="true"
href="https://github.com/ezra-project/node-sword-interface/blob/ba3a0347fbe9a19cec5bd3daac080c5325dc7393/src/sword_backend/module_helper.cpp#L113">getChapterVerseCount.</a>
These methods use the getChapterMax() and getVerseMax() functions
from SWORD.<br>
</p>
<p>Based on my new helper methods, I then refactored my code in the
frontend a bit and saw a decent performance improvement after that
(saving 800ms on startup time when directly loading a book).</p>
<p>Best regards,<br>
Tobias<br>
</p>
<div class="moz-cite-prefix">On 11/18/20 7:53 AM, Tobias Klein
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:0131baee-30f1-297b-6b93-00bb24b22c1f@tklein.info">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<blockquote type="cite"
cite="mid:f655b595-327d-e3ad-d581-8daa5cf4fe30@crosswire.org">I
am note sure I condone this behavior here :) If you found a
need to do something like this because you couldn't easily use
the suggestions below, please let me know and maybe we can fix
something or extend functionality to meet your needs.<br>
<p>If you ever want to know how many Books, Chapters, Verses,
etc. are available in a reference system, these should serve
that purpose:<br>
</p>
<p>VerseKey::getTestamentMax()</p>
<p>VerseKey::getBookMax(), once you set the testament<br>
</p>
<p>VerseKey::getChapterMax(), once you set the book<br>
</p>
<p>VerseKey::getVerseMax(), once you set the chapter<br>
</p>
</blockquote>
<p>At the time when I wrote that function I didn't realize that I
could use VerseKey to determine max values of
chapters/chapter-verses per book.<br>
Thanks! I may actually refactor my code now based on your hint.<br>
<br>
To give you some context how I use this function ... in Ezra
Project, this is currently used in three places.<br>
1) NavigationPane => Getting the number of chapters for a
book<br>
2) I have a "verse range formatter", that needs the verse count
per chapter to work correctly.<br>
3) In my TagStatistics function I calculate percentages relative
to the total number of verses in a book.<br>
</p>
<p>Best regards,<br>
Tobias</p>
</blockquote>
</body>
</html>