Uploaded image for project: 'JSword'
  1. JSword
  2. JS-134

JDOM Upgrade and Optimisation

    Details

      Description

      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; }

        Attachments

          Activity

            People

            • Assignee:
              dmsmith DM Smith
              Reporter:
              mjdenham Martin Denham
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: