<div dir="ltr">Hi<div><br></div><div>I'm looking to refactor Books.installed().getBook(name) because it takes too long when you need to look up books multiple times (and don't have an easy way of caching the JSword lookup). It's particular slow when you have 200+ resources (our server will have). This will also be more prevalent in Android where method calls are quite expensive.</div>
<div><br></div><div>In STEP we always have the initials of the module (the user selects by name/initials/STEP name in the browser, where it always gets translated to initials well before it hits JSword). Do any other frontends use the getBook(name) by name?</div>
<div><br></div><div>I want to at least provide way of getting the book directly from its initials. As part of this, we can several things:</div><div><br></div><div>In Books:</div><div>- refactor the getBook() method to not search first against the name, then against name insensitive and then against the initials in the BMD, and then against the initials directly</div>
<div>- If the above is not possible then at least provide a getBookByInitials (which would just look up the initials against their lower case value.</div><div><br></div><div>In BookSet:</div><div>- I can't work out why we're sorting the inserts in add(). They cause unecessary copies of the ArrayList contents in the creation of it.</div>
<div>- I can't work out why it also implements Set. Especially, since contains would be a good candidate for using </div><div><br></div><div><br></div><div>So there are two options really:</div><div>- change BookSet to be based on a Map. getBooksByInitials would use the map directly. getBook would iterate through the contents (or key the contents in a separate map for faster access)</div>
<div>- Add a map to BookSet to cache the lookups</div><div><br></div><div>My preference would be to replace the BookSet implementation altogether. But the easy option would be to have a Map lookup. Do we use any of the Set<> methods? Would it make sense to replace BookSet with a LinkedHashMap?</div>
<div><br></div><div><br></div><div>Chris</div><div><br></div></div>