[jdom-interest] Presences of Namespace dramatically slows SAXBuilder

tim at peierls.net tim at peierls.net
Thu Apr 12 11:23:08 PDT 2001


This is in reply to Jason Hunter's message of Tue, 03 Apr 2001 12:52:08 -0700. (I just subscribed to jdom-interest, so I don't have an actual message to reply to.)

> [Jason Hunter wrote:] ... I did a little OptimizeIt testing and found 
> that one line was taking the vast bulk of time:
> 
>   availableNamespaces.remove(element.getAdditionalNamespaces());
>
> I changed it to:
>
>   List addl = element.getAdditionalNamespaces();
>   if (addl.size() > 0) {
>       availableNamespaces.remove(addl);
>   }

Both of these look wrong to me. Shouldn't it simply be

  availableNamespaces.removeAll(element.getAdditionalNamespaces());

?

The remove() method removes a single element from a Collection. removeAll() removes all the elements of the argument collection from the target collection. The current code would never remove _any_ namespaces from availableNamespaces, which can't be right.

On a related note, shouldn't availableNamespaces be declared as a List rather than a LinkedList? It doesn't make use of any special linked list capabilities, does it?

--tim





More information about the jdom-interest mailing list