[jsword-devel] [JIRA] Commented: (JS-134) JDOM Upgrade and Optimisation

DM Smith (JIRA) jira at crosswire.org
Tue Nov 30 08:46:38 MST 2010


    [ http://www.crosswire.org/bugs/browse/JS-134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13587#action_13587 ] 

DM Smith commented on JS-134:
-----------------------------

The probable reason that making SAXBuilder a member variable did not give much benefit was that every call to getFilter() returned a brand new, cloned filter. This was in the heart of many loops. I changed the classes that called getFilter to have a member variable "filter" that was populated by a call to getFilter().

Now it should show a bigger benefit.

> JDOM Upgrade and Optimisation
> -----------------------------
>
>                 Key: JS-134
>                 URL: http://www.crosswire.org/bugs/browse/JS-134
>             Project: JSword
>          Issue Type: Improvement
>          Components: o.c.jsword.book.filter.osis
>         Environment: Android
>            Reporter: Martin Denham
>            Assignee: DM Smith
>            Priority: Minor
>
> Only JDOM version 1.1.1 is compatible with Android so in my copy I upgraded JSword's JDOM 1.0 to 1.1.1 which caused no issues because JDOM is so stable and well tested.
> JDOM 1.1.1 also provides a new SAXBuilder flag for faster parsing (see second paragraph of jdom.org) which I think is SAXBuilder.setFastReconfigure() which has this description:
> "Specifies whether this builder will do fast reconfiguration of the underlying SAX parser when reuseParser is true. This improves performance in cases where SAXBuilders are reused and lots of small documents are frequently parsed. This avoids attempting to set features on the SAX parser each time build() is called which result in SaxNotRecognizedExceptions."
> I added this flag to OSISFilter and OSIS parsing was improved by about 20%.  My tests monitored the time from the first OSISFilter.parse() to the last parse() so it is not a 20% improvement on the whole time it takes to show a chapter.
> Here is And Bible's code from OSISFilter with the one line change:
>     private Element parse(String plain) throws JDOMException, IOException {
>         // create a root element to house our document fragment
>         StringReader in = new StringReader("<div>" + plain + "</div>"); //$NON-NLS-1$ //$NON-NLS-2$
>         InputSource is = new InputSource(in);
>         SAXBuilder builder = new SAXBuilder();
>         //MJD START
>         builder.setFastReconfigure(true);
>         //MJD END
>         Document doc = builder.build(is);
>         Element div = doc.getRootElement();
>         return div;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://www.crosswire.org/bugs/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jsword-devel mailing list