Ok,
Seems like a silly design choice as String.equals does this
public boolean equals(Object anObject) {
if (this == anObject) {
return true;
}
....
....
There are over 30 String comparisons using == throughout the code, btw.
But thanks for clearing that up.
Quoting Michael Glavassevich <[EMAIL PROTECTED]>:
> Hello Dave,
>
> If you've been looking through the source code you'll notice that in many
> places we compare strings by reference instead of calling equals. For
> performance reasons Xerces keeps a table of unique strings for XML names
> (elements, attributes, entities, etc...) and namespace names (URIs). These
> strings have all been internalized (by calling String.intern()) so unique
> references for names and namespace names are passed through the parser's
> components. Methods which are part of the public API cannot take advantage
> of this because a user may pass a reference to some other string object,
> however this method is not part of the DOM API. I did a search for
> references to this method using Eclipse and it seems that it's not being
> called anywhere.
>
> Thanks.
>
> "Dave Brosius" <[EMAIL PROTECTED]> wrote on 07/07/2004 10:29:47 PM:
>
> > I ran across this in org.apache.xerces.dom.DeferredDocumentImpl
> >
> > Shouldn't this be
> >
> > if (getChunkValue(fNodeName, achunk, aindex).equals( name))
> {
> >
> > ?
> >
> >
> > public String getAttribute(int elemIndex, String name) {
> > if (elemIndex == -1 || name == null) {
> > return null;
> > }
> > int echunk = elemIndex >> CHUNK_SHIFT;
> > int eindex = elemIndex & CHUNK_MASK;
> > int attrIndex = getChunkIndex(fNodeExtra, echunk, eindex);
> > while (attrIndex != -1) {
> > int achunk = attrIndex >> CHUNK_SHIFT;
> > int aindex = attrIndex & CHUNK_MASK;
> > if (getChunkValue(fNodeName, achunk, aindex) == name) {
> > return getChunkValue(fNodeValue, achunk, aindex);
> > }
> > attrIndex = getChunkIndex(fNodePrevSib, achunk, aindex);
> > }
> > return null;
> > }
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: [EMAIL PROTECTED]
> E-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]