You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ca...@apache.org on 2004/01/12 23:01:02 UTC
cvs commit: xml-xerces/c/src/xercesc/util XMLUri.cpp XMLUri.hpp
cargilld 2004/01/12 14:01:02
Modified: c/src/xercesc/util XMLUri.cpp XMLUri.hpp
Log:
Minor performance change for handling reserved and unreserved characters.
Revision Changes Path
1.22 +16 -11 xml-xerces/c/src/xercesc/util/XMLUri.cpp
Index: XMLUri.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUri.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- XMLUri.cpp 12 Jan 2004 16:23:39 -0000 1.21
+++ XMLUri.cpp 12 Jan 2004 22:01:02 -0000 1.22
@@ -94,6 +94,16 @@
chAsterisk, chSingleQuote, chOpenParen, chCloseParen, chNull
};
+// combination of MARK and RESERVED
+const XMLCh XMLUri::MARK_OR_RESERVED_CHARACTERS[] =
+{
+ chDash, chUnderscore, chPeriod, chBang, chTilde,
+ chAsterisk, chSingleQuote, chOpenParen, chCloseParen,
+ chSemiColon, chForwardSlash, chQuestion, chColon, chAt,
+ chAmpersand, chEqual, chPlus, chDollarSign, chComma, chOpenSquare,
+ chCloseSquare, chNull
+};
+
//
// scheme = alpha *( alpha | digit | "+" | "-" | "." )
//
@@ -970,8 +980,7 @@
// I've interpreted as an error in the spec, since the
// production should be equivalent to (uric - '/'), and uric
// contains '[' and ']'.
- else if (!isUnreservedCharacter(testChar) &&
- !isReservedCharacter(testChar))
+ else if (!isReservedOrUnreservedCharacter(testChar))
{
XMLCh value1[BUF_LEN+1];
value1[0] = testChar;
@@ -1025,8 +1034,7 @@
, fMemoryManager);
}
}
- else if (!isUnreservedCharacter(testChar) &&
- !isReservedCharacter(testChar))
+ else if (!isReservedOrUnreservedCharacter(testChar))
{
XMLCh value1[BUF_LEN+1];
value1[0] = testChar;
@@ -1077,8 +1085,7 @@
, fMemoryManager);
}
}
- else if (!isUnreservedCharacter(testChar) &&
- !isReservedCharacter(testChar))
+ else if (!isReservedOrUnreservedCharacter(testChar))
{
XMLCh value1[BUF_LEN+1];
value1[0] = testChar;
@@ -1640,8 +1647,7 @@
const XMLCh* tmpStr = uricString;
while (*tmpStr)
{
- if (isReservedCharacter(*tmpStr) ||
- isUnreservedCharacter(*tmpStr) )
+ if (isReservedOrUnreservedCharacter(*tmpStr))
{
tmpStr++;
}
@@ -2525,8 +2531,7 @@
!XMLString::isHex(pathStr[index+2]))
return false;
}
- else if (!isUnreservedCharacter(testChar) &&
- !isReservedCharacter(testChar))
+ else if (!isReservedOrUnreservedCharacter(testChar))
{
return false;
}
1.16 +18 -1 xml-xerces/c/src/xercesc/util/XMLUri.hpp
Index: XMLUri.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUri.hpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- XMLUri.hpp 17 Dec 2003 00:18:35 -0000 1.15
+++ XMLUri.hpp 12 Jan 2004 22:01:02 -0000 1.16
@@ -57,6 +57,9 @@
/*
* $Id$
* $Log$
+ * Revision 1.16 2004/01/12 22:01:02 cargilld
+ * Minor performance change for handling reserved and unreserved characters.
+ *
* Revision 1.15 2003/12/17 00:18:35 cargilld
* Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
*
@@ -425,6 +428,7 @@
private:
+ static const XMLCh MARK_OR_RESERVED_CHARACTERS[];
static const XMLCh RESERVED_CHARACTERS[];
static const XMLCh MARK_CHARACTERS[];
static const XMLCh SCHEME_CHARACTERS[];
@@ -461,6 +465,13 @@
static bool isUnreservedCharacter(const XMLCh theChar);
/**
+ * Determine whether a char is an reserved or unreserved character.
+ *
+ * @return true if the char is reserved or unreserved, false otherwise
+ */
+ static bool isReservedOrUnreservedCharacter(const XMLCh theChar);
+
+ /**
* Determine whether a scheme conforms to the rules for a scheme name.
* A scheme is conformant if it starts with an alphanumeric, and
* contains only alphanumerics, '+','-' and '.'.
@@ -739,6 +750,12 @@
// ---------------------------------------------------------------------------
// XMLUri: Helper methods
// ---------------------------------------------------------------------------
+inline bool XMLUri::isReservedOrUnreservedCharacter(const XMLCh theChar)
+{
+ return (XMLString::isAlphaNum(theChar) ||
+ XMLString::indexOf(MARK_OR_RESERVED_CHARACTERS, theChar) != -1);
+}
+
inline bool XMLUri::isReservedCharacter(const XMLCh theChar)
{
return (XMLString::indexOf(RESERVED_CHARACTERS, theChar) != -1);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org