You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2005/11/21 07:32:37 UTC
svn commit: r345851 - in /xerces/java/trunk/src/org/apache/xerces/dom:
ChildNode.java ParentNode.java TextImpl.java
Author: mrglavas
Date: Sun Nov 20 22:32:34 2005
New Revision: 345851
URL: http://svn.apache.org/viewcvs?rev=345851&view=rev
Log:
Reverting a questionable performance "improvement" made for resuing
StringBuffers. A reference to a StringBuffer was added to ChildNode
which noticably increased the footprint of the entire DOM since
just about every node had this field. This was not a good tradeoff
and it's possible it didn't help performance at all since setting
the length of StringBuffer to zero causes a new char array to be
created internally. Thanks to Ken Geis who pointed out this problem
on j-dev@xerces.apache.org.
Modified:
xerces/java/trunk/src/org/apache/xerces/dom/ChildNode.java
xerces/java/trunk/src/org/apache/xerces/dom/ParentNode.java
xerces/java/trunk/src/org/apache/xerces/dom/TextImpl.java
Modified: xerces/java/trunk/src/org/apache/xerces/dom/ChildNode.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/dom/ChildNode.java?rev=345851&r1=345850&r2=345851&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/ChildNode.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/ChildNode.java Sun Nov 20 22:32:34 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2002,2004 The Apache Software Foundation.
+ * Copyright 2000-2002,2004,2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,8 +35,6 @@
/** Serialization version. */
static final long serialVersionUID = -6112455738802414002L;
-
- transient StringBuffer fBufferStr = null;
//
// Data
Modified: xerces/java/trunk/src/org/apache/xerces/dom/ParentNode.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/dom/ParentNode.java?rev=345851&r1=345850&r2=345851&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/ParentNode.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/ParentNode.java Sun Nov 20 22:32:34 2005
@@ -617,14 +617,9 @@
if (next == null) {
return hasTextContent(child) ? ((NodeImpl) child).getTextContent() : "";
}
- if (fBufferStr == null){
- fBufferStr = new StringBuffer();
- }
- else {
- fBufferStr.setLength(0);
- }
- getTextContent(fBufferStr);
- return fBufferStr.toString();
+ StringBuffer buf = new StringBuffer();
+ getTextContent(buf);
+ return buf.toString();
}
return "";
}
Modified: xerces/java/trunk/src/org/apache/xerces/dom/TextImpl.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/dom/TextImpl.java?rev=345851&r1=345850&r2=345851&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/TextImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/TextImpl.java Sun Nov 20 22:32:34 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Copyright 1999-2002,2004,2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -142,28 +142,23 @@
synchronizeData();
}
- if (fBufferStr == null){
- fBufferStr = new StringBuffer();
- }
- else {
- fBufferStr.setLength(0);
- }
+ StringBuffer buffer = new StringBuffer();
if (data != null && data.length() != 0) {
- fBufferStr.append(data);
+ buffer.append(data);
}
- //concatenate text of logically adjacent text nodes to the left of this node in the tree
- getWholeTextBackward(this.getPreviousSibling(), fBufferStr, this.getParentNode());
- String temp = fBufferStr.toString();
+ // concatenate text of logically adjacent text nodes to the left of this node in the tree
+ getWholeTextBackward(this.getPreviousSibling(), buffer, this.getParentNode());
+ String temp = buffer.toString();
- //clear buffer
- fBufferStr.setLength(0);
+ // clear buffer
+ buffer.setLength(0);
- //concatenate text of logically adjacent text nodes to the right of this node in the tree
- getWholeTextForward(this.getNextSibling(), fBufferStr, this.getParentNode());
+ // concatenate text of logically adjacent text nodes to the right of this node in the tree
+ getWholeTextForward(this.getNextSibling(), buffer, this.getParentNode());
+
+ return temp + buffer.toString();
- return temp + fBufferStr.toString();
-
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org