Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Text.copy

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Text.copy
  • Date: Thu, 25 Nov 2004 15:14:44 -0800

Improves CDATASection, looks good.

On a different, but related issue: I get more and more the impression that the UTF-8 encoding trick to safe memory at the expense of CPU isn't quite worth it. When the text is a constant, or a substring, or from an interning source the UTF trick actually increases memory consumption when used through the normal Text(String) constructor. I'd rather store a plain string and perhaps try to eliminate memory overhead elsewhere (e.g. in namespaces).

Wolfgang.

On Nov 25, 2004, at 3:02 PM, Elliotte Harold wrote:

Wolfgang Hoschek wrote:

How about avoiding verification on copy in Text? It is unnecessary since the text has already been verified before.
It's straightforward:
public Node copy() {
if (isCDATASection()) {
return new CDATASection(this);
}
else {
return build(data);
// return new Text(this);
}
}

OK. I think I can go that one better and avoid the UTF-8 conversion and save a little memory too. How about this:

public Node copy() {

Text copy;
if (this.isCDATASection()) {
copy = new CDATASection();
}
else {
copy = new Text();
}
copy.data = this.data;
return copy;

}

(This also needs the addition of a non-public no-args constructor in CDATASection.)

This would share the data array between the original node and its copy. However, this array is private and is never written to inside the class. It is occasionally replaced, but there's no way to change its contents. (The Text class is like a String in this respect). Thoughts?


--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim





Archive powered by MHonArc 2.6.24.

Top of Page