Hi:

I have a number of SVG files produced by Visio that take a long time (>
20 minutes) to load. I used Jprobe and found that the biggest time sink
was in Batik.dom.svg.SVGOMDocument.getById(). As an experiment, I
replaced the scan of
"protected static Element getById(String id, Node node)" by a hash
table.

Specifically, I added the following in SVGOMDocument.java

    private HashMap elementsWithIDs = new HashMap();

    public void registerElement (String id, Element ele) {
      elementsWithIDs.put(id, ele);
    }

And modified the getElementById() call to:

   public Element getElementById(String elementId) {
        return (Element) elementsWithIDs.get(elementId);
   }

Then to actually, load the hash table, I modified
org.apache.batik.dom.AbstractElement.java to register elements when the
"id" was set. For example, in "public void setAttributeNS()", at the end
I added code

      if (qualifiedName.equals("id")) {
          ((org.apache.batik.dom.svg.SVGOMDocument)getOwnerDocument())
            .registerElement(value, this);
        }

I similarly modified "public void setAttribute()"

The results were dramatic, with the > 20 minute load dropping to just a
few seconds.

What other changes would be necessary to make this change "correct"?

Thanks

Fritz Sieker

[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to