xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Antwort: RE: [XOM-interest] Attributes performance patch
- From: dvholten AT computer.org
- To: xom-interest AT lists.ibiblio.org
- Cc:
- Subject: Antwort: RE: [XOM-interest] Attributes performance patch
- Date: Mon, 22 Nov 2004 13:31:16 GMT
counting cycles doesnt make too much sense when some method-calls are done
inside the loop.
for my taste, i wouldnt use that countdown-loops for 'normal' loops -
they are not the 'standard idiom' for an iteration over some
list-elements.
I stop reading and have to understand how the loops counts: n..0 ? n..1 ??
The standard-loop is a no brainer..
if there really is a hotspot, i would investigate, why the iterator is a
problem here.
tja - here might be a problem: the iterator checks for concurrent
modifications,
the index-access doesnt. What if two calls to Attributes.add() happen at
the same time?
What if Attributes.remove() is called while an add() is under way??
dvholten
>From whoschek AT lbl.gov Mon Nov 22 11:27:14 2004
Return-Path: <whoschek AT lbl.gov>
X-Original-To: xom-interest AT lists.ibiblio.org
Delivered-To: xom-interest AT lists.ibiblio.org
Received: from mta1.lbl.gov (mta1.lbl.gov [128.3.41.24])
by happyhouse.metalab.unc.edu (Postfix) with ESMTP id C792F4C005
for <xom-interest AT lists.ibiblio.org>;
Mon, 22 Nov 2004 11:27:13 -0500 (EST)
Received: from mta1.lbl.gov (localhost [127.0.0.1])
by mta1.lbl.gov (8.12.10/8.12.10) with ESMTP id iAMGRAML025238
for <xom-interest AT lists.ibiblio.org>;
Mon, 22 Nov 2004 08:27:11 -0800 (PST)
Received: from [10.0.1.2] (adsl-67-125-77-9.dsl.snfc21.pacbell.net
[67.125.77.9])
by mta1.lbl.gov (8.12.10/8.12.10) with ESMTP id iAMGRAes025222;
Mon, 22 Nov 2004 08:27:10 -0800 (PST)
In-Reply-To: <41A1C87B.4030903 AT metalab.unc.edu>
References: <C3F8A4B0-3C22-11D9-945B-000A95BD16CE AT lbl.gov>
<41A1C87B.4030903 AT metalab.unc.edu>
Mime-Version: 1.0 (Apple Message framework v619)
Content-Type: text/plain; charset=US-ASCII; format=flowed
Message-Id: <5BD67A40-3CA3-11D9-B6EA-000A95BD16CE AT lbl.gov>
Content-Transfer-Encoding: 7bit
From: Wolfgang Hoschek <whoschek AT lbl.gov>
Subject: Re: [XOM-interest] Attributes performance patch
Date: Mon, 22 Nov 2004 08:27:10 -0800
To: Elliotte Harold <elharo AT metalab.unc.edu>
X-Mailer: Apple Mail (2.619)
Cc: xom-interest AT lists.ibiblio.org
X-BeenThere: xom-interest AT lists.ibiblio.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: xom-interest.lists.ibiblio.org
List-Unsubscribe: <http://lists.ibiblio.org/mailman/listinfo/xom-interest>,
<mailto:xom-interest-request AT lists.ibiblio.org?subject=unsubscribe>
List-Archive: <https://lists.ibiblio.org/sympa/arc/xom-interest>
List-Post: <mailto:xom-interest AT lists.ibiblio.org>
List-Help: <mailto:sympa AT lists.ibiblio.org?subject=HELP>
List-Subscribe: <http://lists.ibiblio.org/mailman/listinfo/xom-interest>,
<mailto:xom-interest-request AT lists.ibiblio.org?subject=subscribe>
X-List-Received-Date: Mon, 22 Nov 2004 16:27:14 -0000
On Nov 22, 2004, at 3:07 AM, Elliotte Harold wrote:
> A fix is in CVS. Thanks for the report.
Attributes copy() {
Attributes result = new Attributes();
int size = attributes.size();
result.attributes.ensureCapacity(size);
for (int i = 0; i < size(); i++) {
result.attributes.add(this.get(i).copy());
}
return result;
}
should better read:
Attributes copy() {
Attributes result = new Attributes();
int size = attributes.size();
result.attributes.ensureCapacity(size);
for (int i = 0; i < size; i++) { // WH DELTA HERE
result.attributes.add(this.get(i).copy());
}
return result;
}
and as stated and documented in my previous mail there is no need to
loop any further, hence
void checkPrefixConflict(Attribute attribute) {
String prefix = attribute.getNamespacePrefix();
String namespaceURI = attribute.getNamespaceURI();
// Look for conflicts
int size = this.size();
for (int i = 0; i < size; i++) {
Attribute a = (Attribute) attributes.get(i);
if (a.getNamespacePrefix().equals(prefix)
&& !(a.getNamespaceURI().equals(namespaceURI))) {
throw new NamespaceConflictException(
"Prefix of " + attribute.getQualifiedName()
+ " conflicts with " + a.getQualifiedName());
}
}
}
should better read:
void checkPrefixConflict(Attribute attribute) {
String prefix = attribute.getNamespacePrefix();
String namespaceURI = attribute.getNamespaceURI();
// Look for conflicts
int size = this.size();
for (int i = 0; i < size; i++) {
Attribute a = (Attribute) attributes.get(i);
// if (a.getNamespacePrefix().equals(prefix)
// && !(a.getNamespaceURI().equals(namespaceURI))) {
// throw new NamespaceConflictException(
// "Prefix of " + attribute.getQualifiedName()
// + " conflicts with " + a.getQualifiedName());
// }
if (a.getNamespacePrefix().equals(prefix)) {
if (a.getNamespaceURI().equals(namespaceURI)) return; //
no need to look further
throw new NamespaceConflictException(
"Prefix of " + attribute.getQualifiedName()
+ " conflicts with " + a.getQualifiedName());
}
}
}
-----------------------------------------------------------------------
Wolfgang Hoschek | email: whoschek AT lbl.gov
Distributed Systems Department | phone: (415)-533-7610
Berkeley Laboratory | http://dsd.lbl.gov/~hoschek/
-----------------------------------------------------------------------
- Antwort: RE: [XOM-interest] Attributes performance patch, dvholten, 11/22/2004
Archive powered by MHonArc 2.6.24.