xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Elliotte Harold <elharo AT metalab.unc.edu>
- To: Wolfgang Hoschek <whoschek AT lbl.gov>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] Serializer performance patches
- Date: Wed, 29 Jun 2005 07:29:46 -0400
Wolfgang Hoschek wrote:
private static final boolean mightNeedAttributeEscaping(String s) { // WH
int length = s.length();
for (int i = 0; i < length; i++) {
switch (s.charAt(i)) {
case '\t': return true;
case '\n': return true;
case '"': return true;
case '\r': return true;
case '&': return true;
case '<': return true;
case '>': return true;
}
}
return false;
}
Why "might"? Is there any case in which this method would return true and attribute escaping would not be needed?
Also I'm guessing a lot of the speedup comes from writing the data as one string, rather than a character at a time. However this approach still needs to loop through the whole string if it's going down the fast path. It can short circuit but the result of that is going down the slow path instead. What if in this loop we simply built up a new StringBuffer containing the escaped string and then wrote that? Could that be faster for both cases? Or would the extra time spent in building the StringBuffer kill any advantages?
--
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
-
[XOM-interest] Serializer performance patches,
Wolfgang Hoschek, 06/29/2005
- Re: [XOM-interest] Serializer performance patches, Elliotte Harold, 06/29/2005
-
Re: [XOM-interest] Serializer performance patches,
Elliotte Harold, 06/29/2005
- Re: [XOM-interest] Serializer performance patches, Wolfgang Hoschek, 06/29/2005
-
Re: [XOM-interest] Serializer performance patches,
Elliotte Harold, 06/29/2005
- Re: [XOM-interest] Serializer performance patches, Wolfgang Hoschek, 06/29/2005
- Re: [XOM-interest] Serializer performance patches, Elliotte Harold, 06/29/2005
-
Re: [XOM-interest] Serializer performance patches,
Elliotte Harold, 06/29/2005
- Re: [XOM-interest] Serializer performance patches, Wolfgang Hoschek, 06/29/2005
- Re: [XOM-interest] Serializer performance patches, Wolfgang Hoschek, 06/29/2005
-
Re: [XOM-interest] Serializer performance patches,
Elliotte Harold, 06/29/2005
-
Re: [XOM-interest] Serializer performance patches,
Wolfgang Hoschek, 06/29/2005
- Re: [XOM-interest] Serializer performance patches, Wolfgang Hoschek, 06/29/2005
-
Re: [XOM-interest] Serializer performance patches,
Wolfgang Hoschek, 06/29/2005
Archive powered by MHonArc 2.6.24.