dbertoni 2003/01/07 22:56:36
Modified: c/src/XMLSupport FormatterToHTML.cpp FormatterToHTML.hpp
Log:
Use more optimistic algorithm to accumulate content. Removed unnecessary code and
parameters. Removed unnecessary strings and string compare operations.
Revision Changes Path
1.83 +97 -96 xml-xalan/c/src/XMLSupport/FormatterToHTML.cpp
Index: FormatterToHTML.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToHTML.cpp,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- FormatterToHTML.cpp 22 Dec 2002 18:00:12 -0000 1.82
+++ FormatterToHTML.cpp 8 Jan 2003 06:56:36 -0000 1.83
@@ -297,7 +297,7 @@
const bool isBlockElement =
elemProperties.is(XalanHTMLElementsProperties::BLOCK);
- if (equalsIgnoreCaseASCII(name, length(name), s_scriptString,
s_scriptStringLength) == true)
+ if (elemProperties.is(XalanHTMLElementsProperties::SCRIPTELEM) == true)
{
m_isScriptOrStyleElem = true;
@@ -305,7 +305,7 @@
}
else
{
- if (equalsIgnoreCaseASCII(name, length(name), s_styleString,
s_styleStringLength) == true)
+ if (elemProperties.is(XalanHTMLElementsProperties::STYLEELEM)
== true)
{
m_isScriptOrStyleElem = true;
}
@@ -531,14 +531,11 @@
bool
FormatterToHTML::accumDefaultEntity(
XalanDOMChar ch,
- XalanDOMString::size_type i,
- const XalanDOMChar chars[],
- XalanDOMString::size_type len,
bool escLF)
{
assert(ch != 0);
- if(FormatterToXML::accumDefaultEntity(ch, i, chars, len, escLF) == true)
+ if(FormatterToXML::accumDefaultEntity(ch, escLF) == true)
{
return true;
}
@@ -632,10 +629,12 @@
const XMLCh* const data)
{
+ const XalanDOMString::size_type dataLength = length(data);
+
// Use a fairly nasty hack to tell if the next node is supposed to be
// unescaped text.
if(equals(target, length(target), s_piTarget, s_piTargetLength) == true &&
- equals(data, length(data), s_piData, s_piDataLength) == true)
+ equals(data, dataLength, s_piData, s_piDataLength) == true)
{
m_nextIsRaw = true;
}
@@ -659,7 +658,7 @@
accumContent(XalanUnicode::charSpace);
}
- writeCharacters(data);
+ writeCharacters(data, dataLength);
}
accumContent(XalanUnicode::charGreaterThanSign); // different from XML
@@ -692,59 +691,74 @@
{
assert(theString != 0);
- if (theLength == XalanDOMString::npos)
- {
- theLength = length(theString);
- }
+ XalanDOMString::size_type i = 0;
+ XalanDOMString::size_type firstIndex = 0;
- for (XalanDOMString::size_type i = 0; i < theLength; ++i)
+ while(i < theLength)
{
const XalanDOMChar ch = theString[i];
if(ch < SPECIALSSIZE && m_charsMap[ch] != 'S')
{
- accumContent(ch);
+ ++i;
}
else if (XalanUnicode::charLF == ch) // sta this can be removed?
{
+ accumContent(theString, firstIndex, i - firstIndex);
+
outputLineSep();
+
+ ++i;
+
+ firstIndex = i;
}
- else if (accumDefaultEntity(ch, i, theString, theLength, true) ==
false)
+ else
{
- if (m_isUTF8 == true && 0xd800 <= ch && ch < 0xdc00)
- {
- // UTF-16 surrogate
- XalanDOMChar next = 0;
+ accumContent(theString, firstIndex, i - firstIndex);
- if (i + 1 >= theLength)
- {
- throwInvalidUTF16SurrogateException(ch);
- }
- else
+ if (accumDefaultEntity(ch, true) == false)
+ {
+ if (m_isUTF8 == true && 0xd800 <= ch && ch < 0xdc00)
{
- next = theString[++i];
+ // UTF-16 surrogate
+ XalanDOMChar next = 0;
- if (!(0xdc00 <= next && next < 0xe000))
+ if (i + 1 >= theLength)
{
-
throwInvalidUTF16SurrogateException(ch, next);
+
throwInvalidUTF16SurrogateException(ch);
}
+ else
+ {
+ next = theString[++i];
- next = XalanDOMChar(((ch - 0xd800) << 10) +
next - 0xdc00 + 0x00010000);
- }
+ if (!(0xdc00 <= next && next < 0xe000))
+ {
+
throwInvalidUTF16SurrogateException(ch, next);
+ }
- writeNumberedEntityReference(next);
- }
- else if(ch >= 0x007Fu && ch <= m_maxCharacter)
- {
- // Hope this is right...
- accumContent(ch);
- }
- else
- {
- writeNumberedEntityReference(ch);
+ next = XalanDOMChar(((ch - 0xd800) <<
10) + next - 0xdc00 + 0x00010000);
+ }
+
+ writeNumberedEntityReference(next);
+ }
+ else if(ch >= 0x007Fu && ch <= m_maxCharacter)
+ {
+ // Hope this is right...
+ accumContent(ch);
+ }
+ else
+ {
+ writeNumberedEntityReference(ch);
+ }
}
+
+ ++i;
+
+ firstIndex = i;
}
}
+
+ accumContent(theString, firstIndex, theLength - firstIndex);
}
@@ -756,58 +770,72 @@
{
assert(theString != 0);
- for (XalanDOMString::size_type i = 0; i < theStringLength; i ++)
+ XalanDOMString::size_type i = 0;
+ XalanDOMString::size_type firstIndex = 0;
+
+ while(i < theStringLength)
{
const XalanDOMChar ch = theString[i];
if(ch < SPECIALSSIZE && m_attrCharsMap[ch] != 'S')
{
- accumContent(ch);
+ ++i;
}
else if(XalanUnicode::charAmpersand == ch &&
i + 1 < theStringLength &&
XalanUnicode::charLeftCurlyBracket == theString[i + 1])
{
- accumContent(ch); // no escaping in this case, as specified in
15.2
+ ++i;
}
- else if (accumDefaultEntity(ch, i, theString, theStringLength, true)
== false)
+ else
{
- if (0xd800 <= ch && ch < 0xdc00)
- {
- // UTF-16 surrogate
-
- XalanDOMChar next = 0;
+ accumContent(theString, firstIndex, i - firstIndex);
- if (i + 1 >= theStringLength)
- {
- throwInvalidUTF16SurrogateException(ch);
- }
- else
+ if (accumDefaultEntity(ch, true) == false)
+ {
+ if (0xd800 <= ch && ch < 0xdc00)
{
- next = theString[++i];
+ // UTF-16 surrogate
+
+ XalanDOMChar next = 0;
- if (!(0xdc00 <= next && next < 0xe000))
+ if (i + 1 >= theStringLength)
{
-
throwInvalidUTF16SurrogateException(ch, next);
+
throwInvalidUTF16SurrogateException(ch);
}
+ else
+ {
+ next = theString[++i];
- next = XalanDOMChar(((ch - 0xd800) << 10) +
next -0xdc00 + 0x00010000);
- }
+ if (!(0xdc00 <= next && next < 0xe000))
+ {
+
throwInvalidUTF16SurrogateException(ch, next);
+ }
- accumContent(XalanUnicode::charAmpersand);
- accumContent(XalanUnicode::charNumberSign);
+ next = XalanDOMChar(((ch - 0xd800) <<
10) + next -0xdc00 + 0x00010000);
+ }
- accumContent(UnsignedLongToDOMString(next,
m_stringBuffer));
- clear(m_stringBuffer);
+ accumContent(XalanUnicode::charAmpersand);
+ accumContent(XalanUnicode::charNumberSign);
- accumContent(XalanUnicode::charSemicolon);
- }
- else
- {
- writeNumberedEntityReference(ch);
+ accumContent(UnsignedLongToDOMString(next,
m_stringBuffer));
+ clear(m_stringBuffer);
+
+ accumContent(XalanUnicode::charSemicolon);
+ }
+ else
+ {
+ writeNumberedEntityReference(ch);
+ }
}
+
+ ++i;
+
+ firstIndex = i;
}
}
+
+ accumContent(theString, firstIndex, theStringLength - firstIndex);
}
@@ -1037,12 +1065,12 @@
}
else
{
- accumDefaultEntity(ch, i, theString, theStringLength,
true);
+ accumDefaultEntity(ch, true);
}
}
else if (ch == XalanUnicode::charAmpersand)
{
- accumDefaultEntity(ch, i, theString, theStringLength, true);
+ accumDefaultEntity(ch, true);
}
else
{
@@ -1450,33 +1478,6 @@
const FormatterToHTML::size_type
FormatterToHTML::s_doctypeHeaderSystemStringLength =
FHTML_SIZE(s_doctypeHeaderSystemString);
-
-const XalanDOMChar
FormatterToHTML::s_scriptString[] =
-{
- XalanUnicode::charLetter_S,
- XalanUnicode::charLetter_C,
- XalanUnicode::charLetter_R,
- XalanUnicode::charLetter_I,
- XalanUnicode::charLetter_P,
- XalanUnicode::charLetter_T,
- 0
-};
-
-const FormatterToHTML::size_type FormatterToHTML::s_scriptStringLength =
- FHTML_SIZE(s_scriptString);
-
-const XalanDOMChar
FormatterToHTML::s_styleString[] =
-{
- XalanUnicode::charLetter_S,
- XalanUnicode::charLetter_T,
- XalanUnicode::charLetter_Y,
- XalanUnicode::charLetter_L,
- XalanUnicode::charLetter_E,
- 0
-};
-
-const FormatterToHTML::size_type FormatterToHTML::s_styleStringLength =
- FHTML_SIZE(s_styleString);
const XalanDOMChar
FormatterToHTML::s_metaString[] =
{
1.40 +1 -18 xml-xalan/c/src/XMLSupport/FormatterToHTML.hpp
Index: FormatterToHTML.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToHTML.hpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- FormatterToHTML.hpp 22 Dec 2002 18:00:12 -0000 1.39
+++ FormatterToHTML.hpp 8 Jan 2003 06:56:36 -0000 1.40
@@ -154,9 +154,6 @@
virtual bool
accumDefaultEntity(
XalanDOMChar ch,
- XalanDOMString::size_type i,
- const XalanDOMChar chars[],
- XalanDOMString::size_type len,
bool escLF);
// These methods are inherited from FormatterListener ...
@@ -214,7 +211,7 @@
void
writeCharacters(
const XalanDOMChar* theString,
- XalanDOMString::size_type theLength =
XalanDOMString::npos);
+ XalanDOMString::size_type theLength);
private:
@@ -240,20 +237,6 @@
static const XalanDOMChar s_doctypeHeaderSystemString[];
static const size_type s_doctypeHeaderSystemStringLength;
-
- /**
- * The string "SCRIPT".
- */
- static const XalanDOMChar s_scriptString[];
-
- static const size_type s_scriptStringLength;
-
- /**
- * The string "STYLE".
- */
- static const XalanDOMChar s_styleString[];
-
- static const size_type s_styleStringLength;
/**
* The string "<META http-equiv=\"Content-Type\" content=\"text/html;
charset=".
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]