xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Wolfgang Hoschek <whoschek AT lbl.gov>
- To: elliotte Harold <elharo AT metalab.unc.edu>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] Serializer performance patches
- Date: Wed, 29 Jun 2005 14:54:13 -0700
Ah, I can now see the issue. Here is a revised patch that retains essentially the same performance I've mentioned before. It runs through all xom-1.0 tests (yes, I'm sticking with 1.0 for the time being).
final void writePCDATA(String s) throws IOException {
if (normalize) {
s = Normalizer.normalize(s, Normalizer.NFC);
}
// if (isUnicodeWriter && !mightNeedPCDATAEscaping(s)) { // WH
int columns;
if (isUnicodeWriter && (columns = mightNeedPCDATAEscaping(s)) >= 0) { // WH
out.write(s);
if (columns > 0) {
column += columns;
lastCharacterWasSpace = false;
skipFollowingLinefeed = false;
justBroke=false;
}
return;
}
int length = s.length();
for (int i=0; i < length; i++) {
writePCDATA(s.charAt(i));
}
}
final private static int mightNeedPCDATAEscaping(String s) { // WH
int columns = 0;
int length = s.length();
for (int i = 0; i < length; i++) {
char c = s.charAt(i);
if (c < 0xd800 || c > 0xDBFF) columns++;
switch (c) {
case '&': return -1;
case '<': return -1;
case '>': return -1;
case '\r':return -1;
case '\t': return -1;
case '\n': return -1;
case ' ': return -1;
}
}
return columns;
}
final void writeAttributeValue(String s)
throws IOException {
if (normalize) {
s = Normalizer.normalize(s, Normalizer.NFC);
}
// if (isUnicodeWriter && !mightNeedAttributeEscaping(s)) { // WH
int columns;
if (isUnicodeWriter && (columns = mightNeedAttributeEscaping (s)) >= 0) { // WH
out.write(s);
if (columns > 0) {
column += columns;
lastCharacterWasSpace = false;
skipFollowingLinefeed = false;
justBroke=false;
}
return;
}
int length = s.length();
for (int i=0; i < length; i++) {
writeAttributeValue(s.charAt(i));
}
}
private static final int mightNeedAttributeEscaping(String s) { // WH
int columns = 0;
int length = s.length();
for (int i = 0; i < length; i++) {
char c = s.charAt(i);
if (c < 0xd800 || c > 0xDBFF) columns++;
switch (c) {
case '\t': return -1;
case '\n': return -1;
case '"': return -1;
case '\r': return -1;
case '&': return -1;
case '<': return -1;
case '>': return -1;
case ' ': return -1;
}
}
return columns;
}
final void writeMarkup(String s) throws IOException {
if (normalize) {
s = Normalizer.normalize(s, Normalizer.NFC);
}
int columns;
if (isUnicodeWriter && (columns = mightNeedMarkupEscaping(s)) >= 0) { // WH
out.write(s);
if (columns > 0) {
column += columns;
lastCharacterWasSpace = false;
skipFollowingLinefeed = false;
justBroke=false;
}
return;
}
int length = s.length();
for (int i=0; i < length; i++) {
writeMarkup(s.charAt(i));
}
}
final private static int mightNeedMarkupEscaping(String s) { // WH
int columns = 0;
int length = s.length();
for (int i = 0; i < length; i++) {
char c = s.charAt(i);
if (c < 0xd800 || c > 0xDBFF) columns++;
switch (c) {
case '\t': return -1;
case '\n': return -1;
case ' ': return -1;
}
}
return columns;
}
-
Re: [XOM-interest] Serializer performance patches
, (continued)
-
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, Elliotte Harold, 06/29/2005
-
Re: [XOM-interest] Serializer performance patches,
Robert Koberg, 06/29/2005
- Re: [XOM-interest] Serializer performance patches, Michael Kay, 06/29/2005
-
Re: [XOM-interest] Serializer performance patches,
Wolfgang Hoschek, 06/29/2005
- Re: [XOM-interest] Serializer performance patches, Elliotte Harold, 06/30/2005
-
Re: [XOM-interest] Serializer performance patches,
Elliotte Harold, 06/30/2005
- Re: [XOM-interest] Serializer performance patches, Wolfgang Hoschek, 06/30/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,
Andrew Stewart, 06/30/2005
- Re: [XOM-interest] Serializer performance patches, Elliotte Harold, 06/30/2005
-
Re: [XOM-interest] Serializer performance patches,
Elliotte Harold, 06/29/2005
Archive powered by MHonArc 2.6.24.