You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2002/11/28 19:17:23 UTC
cvs commit: xml-xerces/c/src/xercesc/internal XMLReader.hpp XMLReader.cpp
knoaman 2002/11/28 10:17:23
Modified: c/src/xercesc/internal XMLReader.hpp XMLReader.cpp
Log:
Performance: make getNextChar/peekNextChar inline.
Revision Changes Path
1.6 +120 -0 xml-xerces/c/src/xercesc/internal/XMLReader.hpp
Index: XMLReader.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLReader.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLReader.hpp 25 Nov 2002 21:31:08 -0000 1.5
+++ XMLReader.hpp 28 Nov 2002 18:17:22 -0000 1.6
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.6 2002/11/28 18:17:22 knoaman
+ * Performance: make getNextChar/peekNextChar inline.
+ *
* Revision 1.5 2002/11/25 21:31:08 tng
* Performance:
* 1. use XMLRecognizer::Encodings enum to make new transcode, faster than comparing the encoding string every time.
@@ -853,6 +856,121 @@
}
return true;
}
+
+// ---------------------------------------------------------------------------
+// XMLReader: getNextChar() method inlined for speed
+// ---------------------------------------------------------------------------
+inline bool XMLReader::getNextChar(XMLCh& chGotten)
+{
+ //
+ // See if there is at least a char in the buffer. Else, do the buffer
+ // reload logic.
+ //
+ if (fCharIndex >= fCharsAvail)
+ {
+ // If fNoMore is set, then we have nothing else to give
+ if (fNoMore)
+ return false;
+
+ // If the buffer is empty, then try to refresh
+ if (fCharIndex == fCharsAvail)
+ {
+ refreshCharBuffer();
+
+ // If still empty, then return false
+ if (fCharIndex == fCharsAvail)
+ return false;
+ }
+
+ }
+
+ chGotten = fCharBuf[fCharIndex++];
+
+ // Handle end of line normalization and line/col member maintenance.
+ if (chGotten == chCR)
+ {
+ //
+ // Do the normalization. We return chLF regardless of which was
+ // found. We also eat a chCR followed by an chLF.
+ //
+ // We only do this if the content being spooled is not already
+ // internalized.
+ //
+ if (fSource == Source_External)
+ {
+ //
+ // See if we have another char left. If not, don't bother.
+ // Else, see if its an chLF to eat. If it is, bump the
+ // index again.
+ //
+ if ((fCharIndex < fCharsAvail) || refreshCharBuffer())
+ {
+ if (fCharBuf[fCharIndex] == chLF
+ || ((fCharBuf[fCharIndex] == chNEL) && fNEL))
+ fCharIndex++;
+ }
+
+ // And return just an chLF
+ chGotten = chLF;
+ }
+
+ // And handle the line/col stuff
+ fCurCol = 1;
+ fCurLine++;
+ }
+ else if (chGotten == chLF
+ || ((chGotten == chNEL) && fNEL))
+ {
+ chGotten = chLF;
+ fCurLine++;
+ fCurCol = 1;
+ }
+ else if (chGotten)
+ {
+ //
+ // Only do this is not a null char. Null chars are not part of the
+ // real content. They are just marker characters inserted into
+ // the stream.
+ //
+ fCurCol++;
+ }
+ return true;
+}
+
+
+// ---------------------------------------------------------------------------
+// XMLReader: peekNextChar() method inlined for speed
+// ---------------------------------------------------------------------------
+inline bool XMLReader::peekNextChar(XMLCh& chGotten)
+{
+ //
+ // If there is something still in the buffer, get it. Else do the reload
+ // scenario.
+ //
+ if (fCharIndex >= fCharsAvail)
+ {
+ // Try to refresh the buffer
+ if (!refreshCharBuffer())
+ {
+ chGotten = chNull;
+ return false;
+ }
+ }
+
+ chGotten = fCharBuf[fCharIndex];
+
+ //
+ // Even though we are only peeking, we have to act the same as the
+ // normal char get method in regards to newline normalization, though
+ // its not as complicated as the actual character getting method's.
+ //
+ if ((chGotten == chCR || ((chGotten == chNEL) && fNEL))
+ && (fSource == Source_External))
+ chGotten = chLF;
+
+ return true;
+}
+
XERCES_CPP_NAMESPACE_END
1.7 +1 -113 xml-xerces/c/src/xercesc/internal/XMLReader.cpp
Index: XMLReader.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLReader.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XMLReader.cpp 25 Nov 2002 21:31:08 -0000 1.6
+++ XMLReader.cpp 28 Nov 2002 18:17:22 -0000 1.7
@@ -672,86 +672,6 @@
return !toFill.isEmpty();
}
-bool XMLReader::getNextChar(XMLCh& chGotten)
-{
- //
- // See if there is at least a char in the buffer. Else, do the buffer
- // reload logic.
- //
- if (fCharIndex >= fCharsAvail)
- {
- // If fNoMore is set, then we have nothing else to give
- if (fNoMore)
- return false;
-
- // If the buffer is empty, then try to refresh
- if (fCharIndex == fCharsAvail)
- {
- refreshCharBuffer();
-
- // If still empty, then return false
- if (fCharIndex == fCharsAvail)
- return false;
- }
-
- }
-
- chGotten = fCharBuf[fCharIndex++];
-
- // Handle end of line normalization and line/col member maintenance.
- if (chGotten == chCR)
- {
- //
- // Do the normalization. We return chLF regardless of which was
- // found. We also eat a chCR followed by an chLF.
- //
- // We only do this if the content being spooled is not already
- // internalized.
- //
- if (fSource == Source_External)
- {
- //
- // See if we have another char left. If not, don't bother.
- // Else, see if its an chLF to eat. If it is, bump the
- // index again.
- //
- if ((fCharIndex < fCharsAvail) || refreshCharBuffer())
- {
- if (fCharBuf[fCharIndex] == chLF
- || ((fCharBuf[fCharIndex] == chNEL) && fNEL))
- fCharIndex++;
- }
-
- // And return just an chLF
- chGotten = chLF;
- }
-
- // And handle the line/col stuff
- fCurCol = 1;
- fCurLine++;
- }
- else if (chGotten == chLF
- || ((chGotten == chNEL) && fNEL))
- {
- chGotten = chLF;
- fCurLine++;
- fCurCol = 1;
- }
- else if (chGotten)
- {
- //
- // Only do this is not a null char. Null chars are not part of the
- // real content. They are just marker characters inserted into
- // the stream.
- //
- fCurCol++;
- }
- return true;
-}
-
-
-
-
bool XMLReader::getSpaces(XMLBuffer& toFill)
{
@@ -917,38 +837,6 @@
return false;
}
-
-
-bool XMLReader::peekNextChar(XMLCh& chGotten)
-{
- //
- // If there is something still in the buffer, get it. Else do the reload
- // scenario.
- //
- if (fCharIndex >= fCharsAvail)
- {
- // Try to refresh the buffer
- if (!refreshCharBuffer())
- {
- chGotten = chNull;
- return false;
- }
- }
-
- chGotten = fCharBuf[fCharIndex];
-
- //
- // Even though we are only peeking, we have to act the same as the
- // normal char get method in regards to newline normalization, though
- // its not as complicated as the actual character getting method's.
- //
- if ((chGotten == chCR || ((chGotten == chNEL) && fNEL))
- && (fSource == Source_External))
- chGotten = chLF;
-
- return true;
-}
-
bool XMLReader::skipIfQuote(XMLCh& chGotten)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org