knoaman 2003/08/13 19:57:27 Modified: c/src/xercesc/util XMLBigDecimal.cpp XMLBigDecimal.hpp XMLChar.hpp XMLDateTime.cpp XMLDateTime.hpp XMLURL.cpp XMLURL.hpp c/src/xercesc/util/regx RegularExpression.cpp RegularExpression.hpp Log: Code refactoring to improve performance of validation. Revision Changes Path 1.10 +40 -15 xml-xerces/c/src/xercesc/util/XMLBigDecimal.cpp Index: XMLBigDecimal.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLBigDecimal.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- XMLBigDecimal.cpp 16 May 2003 06:01:53 -0000 1.9 +++ XMLBigDecimal.cpp 14 Aug 2003 02:57:27 -0000 1.10 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/08/14 02:57:27 knoaman + * Code refactoring to improve performance of validation. + * * Revision 1.9 2003/05/16 06:01:53 knoaman * Partial implementation of the configurable memory manager. * @@ -113,10 +116,9 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/util/XMLBigDecimal.hpp> -#include <xercesc/util/PlatformUtils.hpp> #include <xercesc/util/TransService.hpp> #include <xercesc/util/NumberFormatException.hpp> -#include <xercesc/util/XMLUniDefs.hpp> +#include <xercesc/util/XMLChar.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -142,8 +144,9 @@ : fSign(0) , fTotalDigits(0) , fScale(0) -, fIntVal(0) +, fRawDataLen(0) , fRawData(0) +, fIntVal(0) , fMemoryManager(manager) { if ((!strValue) || (!*strValue)) @@ -151,8 +154,14 @@ try { - parseBigDecimal(strValue); - fRawData = XMLString::replicate(strValue, fMemoryManager); + fRawDataLen = XMLString::stringLen(strValue); + fRawData = (XMLCh*) fMemoryManager->allocate + ( + ((fRawDataLen*2) + 2) * sizeof(XMLCh) //fRawData and fIntVal + ); + memcpy(fRawData, strValue, (fRawDataLen+1) * sizeof(XMLCh)); + fIntVal = fRawData + fRawDataLen + 1; + parseBigDecimal(strValue, fRawDataLen); } catch(...) { @@ -168,18 +177,39 @@ void XMLBigDecimal::cleanUp() { - if (fIntVal) - fMemoryManager->deallocate(fIntVal); //delete [] fIntVal; +// if (fIntVal) +// fMemoryManager->deallocate(fIntVal); //delete [] fIntVal; if (fRawData) fMemoryManager->deallocate(fRawData); //XMLString::release(&fRawData); } -void XMLBigDecimal::parseBigDecimal(const XMLCh* const toConvert) +void XMLBigDecimal::setDecimalValue(const XMLCh* const strValue) +{ + fScale = fTotalDigits = 0; + unsigned int valueLen = XMLString::stringLen(strValue); + + if (valueLen > fRawDataLen) { + + fMemoryManager->deallocate(fRawData); + fRawDataLen = valueLen; + fRawData = (XMLCh*) fMemoryManager->allocate + ( + ((fRawDataLen*2) + 2) * sizeof(XMLCh) + );//XMLString::replicate(strValue, fMemoryManager); + fIntVal = fRawData + fRawDataLen + 1; + } + + memcpy(fRawData, strValue, (valueLen + 1) * sizeof(XMLCh)); + parseBigDecimal(strValue, valueLen); +} + +void XMLBigDecimal::parseBigDecimal(const XMLCh* const toConvert + , unsigned int toConvertLen) { // Scan past any whitespace. If we hit the end, then return failure const XMLCh* startPtr = toConvert; - while (XMLPlatformUtils::fgTransService->isSpace(*startPtr)) + while (XMLChar1_0::isWhitespace(*startPtr)) startPtr++; if (!*startPtr) @@ -187,7 +217,7 @@ // Start at the end and work back through any whitespace const XMLCh* endPtr = toConvert + XMLString::stringLen(toConvert); - while (XMLPlatformUtils::fgTransService->isSpace(*(endPtr - 1))) + while (XMLChar1_0::isWhitespace(*(endPtr - 1))) endPtr--; // '+' or '-' is allowed only at the first position @@ -211,15 +241,10 @@ if (!*startPtr) { fSign = 0; - fIntVal = (XMLCh*) fMemoryManager->allocate(sizeof(XMLCh)); //new XMLCh[1]; fIntVal[0] = chNull; return; } - fIntVal = (XMLCh*) fMemoryManager->allocate - ( - (endPtr - startPtr + 1) * sizeof(XMLCh) - ); //new XMLCh[endPtr - startPtr + 1]; XMLCh* retPtr = fIntVal; // Scan data 1.11 +12 -3 xml-xerces/c/src/xercesc/util/XMLBigDecimal.hpp Index: XMLBigDecimal.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLBigDecimal.hpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- XMLBigDecimal.hpp 16 May 2003 06:01:53 -0000 1.10 +++ XMLBigDecimal.hpp 14 Aug 2003 02:57:27 -0000 1.11 @@ -121,8 +121,16 @@ */ int toCompare(const XMLBigDecimal& other) const; + /* + * Sets the value to be converted + * + * @param strValue the value to convert + */ + void setDecimalValue(const XMLCh* const strValue); + private: - void parseBigDecimal(const XMLCh* const strValue); + void parseBigDecimal( const XMLCh* const strValue + , unsigned int strValueLen); void cleanUp(); // ----------------------------------------------------------------------- @@ -157,8 +165,9 @@ int fSign; unsigned int fTotalDigits; unsigned int fScale; - XMLCh* fIntVal; + unsigned int fRawDataLen; XMLCh* fRawData; + XMLCh* fIntVal; MemoryManager* fMemoryManager; }; 1.2 +11 -2 xml-xerces/c/src/xercesc/util/XMLChar.hpp Index: XMLChar.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLChar.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- XMLChar.hpp 20 Dec 2002 22:10:21 -0000 1.1 +++ XMLChar.hpp 14 Aug 2003 02:57:27 -0000 1.2 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.2 2003/08/14 02:57:27 knoaman + * Code refactoring to improve performance of validation. + * * Revision 1.1 2002/12/20 22:10:21 tng * XML 1.1 * @@ -130,7 +133,8 @@ static bool isPlainContentChar(const XMLCh toCheck, const XMLCh toCheck2 = 0); static bool isSpecialStartTagChar(const XMLCh toCheck, const XMLCh toCheck2 = 0); static bool isXMLChar(const XMLCh toCheck, const XMLCh toCheck2 = 0); - static bool isWhitespace(const XMLCh toCheck, const XMLCh toCheck2 = 0); + static bool isWhitespace(const XMLCh toCheck); + static bool isWhitespace(const XMLCh toCheck, const XMLCh toCheck2); static bool isControlChar(const XMLCh toCheck, const XMLCh toCheck2 = 0); static bool isPublicIdChar(const XMLCh toCheck, const XMLCh toCheck2 = 0); @@ -222,6 +226,11 @@ return true; } return false; +} + +inline bool XMLChar1_0::isWhitespace(const XMLCh toCheck) +{ + return ((fgCharCharsTable1_0[toCheck] & gWhitespaceCharMask) != 0); } inline bool XMLChar1_0::isWhitespace(const XMLCh toCheck, const XMLCh toCheck2) 1.13 +21 -13 xml-xerces/c/src/xercesc/util/XMLDateTime.cpp Index: XMLDateTime.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLDateTime.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- XMLDateTime.cpp 22 May 2003 02:10:52 -0000 1.12 +++ XMLDateTime.cpp 14 Aug 2003 02:57:27 -0000 1.13 @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.13 2003/08/14 02:57:27 knoaman + * Code refactoring to improve performance of validation. + * * Revision 1.12 2003/05/22 02:10:52 knoaman * Default the memory manager. * @@ -480,7 +483,10 @@ } XMLDateTime::XMLDateTime(MemoryManager* const manager) -: fBuffer(0) +: fStart(0) +, fEnd(0) +, fBufferMaxLen(0) +, fBuffer(0) , fMemoryManager(manager) { reset(); @@ -488,7 +494,10 @@ XMLDateTime::XMLDateTime(const XMLCh* const aString, MemoryManager* const manager) -: fBuffer(0) +: fStart(0) +, fEnd(0) +, fBufferMaxLen(0) +, fBuffer(0) , fMemoryManager(manager) { setBuffer(aString); @@ -499,7 +508,8 @@ // ----------------------------------------------------------------------- XMLDateTime::XMLDateTime(const XMLDateTime &toCopy) -: fBuffer(0) +: fBufferMaxLen(0) +, fBuffer(0) , fMemoryManager(toCopy.fMemoryManager) { copy(toCopy); @@ -1374,18 +1384,16 @@ // int XMLDateTime::parseInt(const int start, const int end) const { + unsigned int retVal = 0; + for (int i=start; i < end; i++) { - XMLCh* strToScan = (XMLCh*) fMemoryManager->allocate - ( - (end - start + 1) * sizeof(XMLCh) - );//new XMLCh[end - start + 1]; - ArrayJanitor<XMLCh> jname(strToScan, fMemoryManager); - XMLString::subString(strToScan, fBuffer, start, end); + if (fBuffer[i] < chDigit_0 || fBuffer[i] > chDigit_9) + break; - unsigned int retVal; - XMLString::textToBin(strToScan, retVal); + retVal = (retVal * 10) + (unsigned int) (fBuffer[i] - chDigit_0); + } - return (int) retVal; + return (int) retVal;; } // 1.9 +28 -14 xml-xerces/c/src/xercesc/util/XMLDateTime.hpp Index: XMLDateTime.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLDateTime.hpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- XMLDateTime.hpp 18 May 2003 14:02:05 -0000 1.8 +++ XMLDateTime.hpp 14 Aug 2003 02:57:27 -0000 1.9 @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.9 2003/08/14 02:57:27 knoaman + * Code refactoring to improve performance of validation. + * * Revision 1.8 2003/05/18 14:02:05 knoaman * Memory manager implementation: pass per instance manager. * @@ -313,6 +316,7 @@ int fTimeZone[TIMEZONE_ARRAYSIZE]; int fStart; int fEnd; + int fBufferMaxLen; XMLCh* fBuffer; MemoryManager* fMemoryManager; }; @@ -320,8 +324,19 @@ inline void XMLDateTime::setBuffer(const XMLCh* const aString) { reset(); - fBuffer = XMLString::replicate(aString, fMemoryManager); - fEnd = XMLString::stringLen(fBuffer); + + fEnd = XMLString::stringLen(aString); + if (fEnd > 0) { + + if (fEnd > fBufferMaxLen) + { + fMemoryManager->deallocate(fBuffer); + fBufferMaxLen = fEnd + 8; + fBuffer = (XMLCh*) fMemoryManager->allocate((fBufferMaxLen+1) * sizeof(XMLCh)); + } + + memcpy(fBuffer, aString, (fEnd+1) * sizeof(XMLCh)); + } } inline void XMLDateTime::reset() @@ -333,11 +348,7 @@ fStart = fEnd = 0; if (fBuffer) - { - fMemoryManager->deallocate(fBuffer);//delete[] fBuffer; - fBuffer = 0; - } - + *fBuffer = 0; } inline void XMLDateTime::copy(const XMLDateTime& rhs) @@ -350,14 +361,17 @@ fStart = rhs.fStart; fEnd = rhs.fEnd; - if (fBuffer) + if (fEnd > 0) { - fMemoryManager->deallocate(fBuffer);//delete[] fBuffer; - fBuffer = 0; - } + if (fEnd > fBufferMaxLen) + { + fMemoryManager->deallocate(fBuffer);//delete[] fBuffer; + fBufferMaxLen = rhs.fBufferMaxLen; + fBuffer = (XMLCh*) fMemoryManager->allocate((fBufferMaxLen+1) * sizeof(XMLCh)); + } - if (rhs.fBuffer) - fBuffer = XMLString::replicate(rhs.fBuffer, fMemoryManager); + memcpy(fBuffer, rhs.fBuffer, (fEnd+1) * sizeof(XMLCh)); + } } inline void XMLDateTime::assertBuffer() const 1.8 +285 -15 xml-xerces/c/src/xercesc/util/XMLURL.cpp Index: XMLURL.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLURL.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- XMLURL.cpp 16 May 2003 06:01:53 -0000 1.7 +++ XMLURL.cpp 14 Aug 2003 02:57:27 -0000 1.8 @@ -135,6 +135,12 @@ // !!! Keep these up to date with list above! static const unsigned int gMaxProtoLen = 4; +static const XMLCh gListOne[] = { chColon, chForwardSlash, chNull }; +static const XMLCh gListTwo[] = { chAt, chNull }; +static const XMLCh gListThree[] = { chColon, chNull }; +static const XMLCh gListFour[] = { chForwardSlash, chNull }; +static const XMLCh gListFive[] = { chPound, chQuestion, chNull }; +static const XMLCh gListSix[] = { chPound, chNull }; // --------------------------------------------------------------------------- // Local methods @@ -926,13 +932,7 @@ // If the : is first, we assume we have a protocol. If the / is first, // then we skip to the host processing. // - static const XMLCh listOne[] = { chColon, chForwardSlash, chNull }; - static const XMLCh listTwo[] = { chAt, chNull }; - static const XMLCh listThree[] = { chColon, chNull }; - static const XMLCh listFour[] = { chForwardSlash, chNull }; - static const XMLCh listFive[] = { chPound, chQuestion, chNull }; - static const XMLCh listSix[] = { chPound, chNull }; - XMLCh* ptr1 = XMLString::findAny(srcPtr, listOne); + XMLCh* ptr1 = XMLString::findAny(srcPtr, gListOne); XMLCh* ptr2; // If we found a protocol, then deal with it @@ -978,7 +978,7 @@ if (*srcPtr) { // Search from here for a / character - ptr1 = XMLString::findAny(srcPtr, listFour); + ptr1 = XMLString::findAny(srcPtr, gListFour); // // If we found something, then the host is between where @@ -1036,7 +1036,7 @@ // find one, then everything between the start of the host data // and the character is the user name. // - ptr1 = XMLString::findAny(fHost, listTwo); + ptr1 = XMLString::findAny(fHost, gListTwo); if (ptr1) { // Get this info out as the user name @@ -1049,7 +1049,7 @@ XMLString::cut(fHost, ptr1 - fHost); // Is there a password inside the user string? - ptr2 = XMLString::findAny(fUser, listThree); + ptr2 = XMLString::findAny(fUser, gListThree); if (ptr2) { // Remove it from the user name string @@ -1067,7 +1067,7 @@ // not at the end of the host data, then lets see if we have a // port trailing the // - ptr1 = XMLString::findAny(fHost, listThree); + ptr1 = XMLString::findAny(fHost, gListThree); if (ptr1) { // Remove it from the host name @@ -1082,7 +1082,7 @@ // If the host ended up empty, then toss is if (!*fHost) { - delete[] fHost; + fMemoryManager->deallocate(fHost);//delete[] fHost; fHost = 0; } } @@ -1098,7 +1098,7 @@ // forward slash character, or relative. Its basically everything up // to the end of the string or to any trailing query or fragment. // - ptr1 = XMLString::findAny(srcPtr, listFive); + ptr1 = XMLString::findAny(srcPtr, gListFive); if (!ptr1) { fMemoryManager->deallocate(fPath);//delete [] fPath; @@ -1137,7 +1137,7 @@ // separator. // srcPtr++; - ptr1 = XMLString::findAny(srcPtr, listSix); + ptr1 = XMLString::findAny(srcPtr, gListSix); fMemoryManager->deallocate(fQuery);//delete [] fQuery; if (!ptr1) { @@ -1165,6 +1165,276 @@ } } +bool XMLURL::parse(const XMLCh* const urlText, XMLURL& xmlURL) +{ + // Simplify things by checking for the psycho scenarios first + if (!*urlText) + return false; + + // Before we start, check if this urlText contains valid uri characters + if (!XMLUri::isURIString(urlText)) + xmlURL.fHasInvalidChar = true; + else + xmlURL.fHasInvalidChar = false; + + // + // The first thing we will do is to check for a file name, so that + // we don't waste time thinking its a URL. If its in the form x:\ + // or x:/ and x is an ASCII letter, then assume that's the deal. + // + if (((*urlText >= chLatin_A) && (*urlText <= chLatin_Z)) + || ((*urlText >= chLatin_a) && (*urlText <= chLatin_z))) + { + if (*(urlText + 1) == chColon) + { + if ((*(urlText + 2) == chForwardSlash) + || (*(urlText + 2) == chBackSlash)) + { + return false; + } + } + } + + // Get a copy of the URL that we can modify + XMLCh* srcCpy = XMLString::replicate(urlText, xmlURL.fMemoryManager); + ArrayJanitor<XMLCh> janSrcCopy(srcCpy, xmlURL.fMemoryManager); + + // + // Get a pointer now that we can run up thrown the source as we parse + // bits and pieces out of it. + // + XMLCh* srcPtr = srcCpy; + + // Run up past any spaces + while (*srcPtr) + { + if (!XMLPlatformUtils::fgTransService->isSpace(*srcPtr)) + break; + srcPtr++; + } + + // Make sure it wasn't all space + if (!*srcPtr) + return false; + + // + // Ok, the next thing we have to do is to find either a / or : character. + // If the : is first, we assume we have a protocol. If the / is first, + // then we skip to the host processing. + // + XMLCh* ptr1 = XMLString::findAny(srcPtr, gListOne); + XMLCh* ptr2; + + // If we found a protocol, then deal with it + if (ptr1) + { + if (*ptr1 == chColon) + { + // Cap the string at the colon + *ptr1 = 0; + + // And try to find it in our list of protocols + xmlURL.fProtocol = lookupByName(srcPtr); + + if (xmlURL.fProtocol == Unknown) + return false; + + // And move our source pointer up past what we've processed + srcPtr = (ptr1 + 1); + } + } + + // + // Ok, next we need to see if we have any host part. If the next + // two characters are //, then we need to check, else move on. + // + if ((*srcPtr == chForwardSlash) && (*(srcPtr + 1) == chForwardSlash)) + { + // Move up past the slashes + srcPtr += 2; + + // + // If we aren't at the end of the string, then there has to be a + // host part at this point. we will just look for the next / char + // or end of string and make all of that the host for now. + // + if (*srcPtr) + { + // Search from here for a / character + ptr1 = XMLString::findAny(srcPtr, gListFour); + + // + // If we found something, then the host is between where + // we are and what we found. Else the host is the rest of + // the content and we are done. If its empty, leave it null. + // + if (ptr1) + { + if (ptr1 != srcPtr) + { + xmlURL.fHost = (XMLCh*) xmlURL.fMemoryManager->allocate + ( + (ptr1 - srcPtr + 1) * sizeof(XMLCh) + );//new XMLCh[(ptr1 - srcPtr) + 1]; + ptr2 = xmlURL.fHost; + while (srcPtr < ptr1) + *ptr2++ = *srcPtr++; + *ptr2 = 0; + } + } + else + { + xmlURL.fHost = XMLString::replicate(srcPtr, xmlURL.fMemoryManager); + + // Update source pointer to the end + srcPtr += XMLString::stringLen(xmlURL.fHost); + } + } + } + else + { + // + // http protocol requires two forward slashes + // we didn't get them, so throw an exception + // + if (xmlURL.fProtocol == HTTP) + return false; + } + + // + // If there was a host part, then we have to grovel through it for + // all the bits and pieces it can hold. + // + if (xmlURL.fHost) + { + // + // Look for a '@' character, which indicates a user name. If we + // find one, then everything between the start of the host data + // and the character is the user name. + // + ptr1 = XMLString::findAny(xmlURL.fHost, gListTwo); + if (ptr1) + { + // Get this info out as the user name + *ptr1 = 0; + xmlURL.fUser = XMLString::replicate(xmlURL.fHost, xmlURL.fMemoryManager); + ptr1++; + + // And now cut these chars from the host string + XMLString::cut(xmlURL.fHost, ptr1 - xmlURL.fHost); + + // Is there a password inside the user string? + ptr2 = XMLString::findAny(xmlURL.fUser, gListThree); + if (ptr2) + { + // Remove it from the user name string + *ptr2 = 0; + + // And copy out the remainder to the password field + ptr2++; + xmlURL.fPassword = XMLString::replicate(ptr2, xmlURL.fMemoryManager); + } + } + + // + // Ok, so now we are at the actual host name, if any. If we are + // not at the end of the host data, then lets see if we have a + // port trailing the + // + ptr1 = XMLString::findAny(xmlURL.fHost, gListThree); + if (ptr1) + { + // Remove it from the host name + *ptr1 = 0; + + // Try to convert it to a numeric port value and store it + ptr1++; + if (!XMLString::textToBin(ptr1, xmlURL.fPortNum)) + return false; + } + + // If the host ended up empty, then toss is + if (!*(xmlURL.fHost)) + { + xmlURL.fMemoryManager->deallocate(xmlURL.fHost);//delete[] fHost; + xmlURL.fHost = 0; + } + } + + // If we are at the end, then we are done now + if (!*srcPtr) + { + return true; + } + + // + // Next is the path part. It can be absolute, i.e. starting with a + // forward slash character, or relative. Its basically everything up + // to the end of the string or to any trailing query or fragment. + // + ptr1 = XMLString::findAny(srcPtr, gListFive); + if (!ptr1) + { + xmlURL.fPath = XMLString::replicate(srcPtr, xmlURL.fMemoryManager); + return true; + } + + // Everything from where we are to what we found is the path + if (ptr1 > srcPtr) + { + xmlURL.fPath = (XMLCh*) xmlURL.fMemoryManager->allocate + ( + (ptr1 - srcPtr + 1) * sizeof(XMLCh) + );//new XMLCh[(ptr1 - srcPtr) + 1]; + ptr2 = xmlURL.fPath; + while (srcPtr < ptr1) + *ptr2++ = *srcPtr++; + *ptr2 = 0; + } + + // + // If we found a fragment, then it is the rest of the string and we + // are done. + // + if (*srcPtr == chPound) + { + srcPtr++; + xmlURL.fFragment = XMLString::replicate(srcPtr, xmlURL.fMemoryManager); + return true; + } + + // + // The query is either the rest of the string, or up to the fragment + // separator. + // + srcPtr++; + ptr1 = XMLString::findAny(srcPtr, gListSix); + if (!ptr1) + { + xmlURL.fQuery = XMLString::replicate(srcPtr, xmlURL.fMemoryManager); + return true; + } + else + { + xmlURL.fQuery = (XMLCh*) xmlURL.fMemoryManager->allocate + ( + (ptr1 - srcPtr + 1) * sizeof(XMLCh) + );//new XMLCh[(ptr1 - srcPtr) + 1]; + ptr2 = xmlURL.fQuery; + while (srcPtr < ptr1) + *ptr2++ = *srcPtr++; + *ptr2 = 0; + } + + // If we are not at the end now, then everything else is the fragment + if (*srcPtr == chPound) + { + srcPtr++; + xmlURL.fFragment = XMLString::replicate(srcPtr, xmlURL.fMemoryManager); + } + + return true; +} XERCES_CPP_NAMESPACE_END 1.10 +2 -2 xml-xerces/c/src/xercesc/util/XMLURL.hpp Index: XMLURL.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLURL.hpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- XMLURL.hpp 18 May 2003 14:02:05 -0000 1.9 +++ XMLURL.hpp 14 Aug 2003 02:57:27 -0000 1.10 @@ -95,7 +95,7 @@ // Public static methods // ----------------------------------------------------------------------- static Protocols lookupByName(const XMLCh* const protoName); - + static bool parse(const XMLCh* urlText, XMLURL& xmlURL); // ----------------------------------------------------------------------- // Constructors and Destructor 1.14 +21 -7 xml-xerces/c/src/xercesc/util/regx/RegularExpression.cpp Index: RegularExpression.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/RegularExpression.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- RegularExpression.cpp 25 May 2003 21:42:41 -0000 1.13 +++ RegularExpression.cpp 14 Aug 2003 02:57:27 -0000 1.14 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2003/08/14 02:57:27 knoaman + * Code refactoring to improve performance of validation. + * * Revision 1.13 2003/05/25 21:42:41 knoaman * Allocate/Deallocate Context::xxx only when necessary. * @@ -171,6 +174,7 @@ , fLimit(0) , fLength(0) , fSize(0) + , fStringMaxLen(0) , fOffsets(0) , fMatch(0) , fString(0) @@ -193,13 +197,24 @@ // RegularExpression::Context: Public methods // --------------------------------------------------------------------------- void RegularExpression::Context::reset(const XMLCh* const string - , const int start, const int limit + , const int stringLen + , const int start + , const int limit , const int noClosures) { - if (fString) - fMemoryManager->deallocate(fString);//delete [] fString; + if (stringLen > fStringMaxLen || !fString) { + + fStringMaxLen = stringLen; + + if (fString) + fMemoryManager->deallocate(fString); + + fString = XMLString::replicate(string, fMemoryManager); + } + else { + memcpy(fString, string, (stringLen + 1) * sizeof(XMLCh)); + } - fString = XMLString::replicate(string, fMemoryManager); fStart = start; fLimit = limit; fLength = fLimit - fStart; @@ -208,7 +223,6 @@ delete fMatch; fMatch = 0; - if (fSize != noClosures) { if (fOffsets) @@ -490,7 +504,7 @@ context = fContext; } - context->reset(expression, start, end, fNoClosures); + context->reset(expression, strLength, start, end, fNoClosures); } Janitor<Context> janContext(tmpContext); @@ -728,7 +742,7 @@ context = fContext; } - context->reset(expression, start, end, fNoClosures); + context->reset(expression, strLength, start, end, fNoClosures); } Janitor<Context> janContext(tmpContext); 1.11 +5 -4 xml-xerces/c/src/xercesc/util/regx/RegularExpression.hpp Index: RegularExpression.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/regx/RegularExpression.hpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- RegularExpression.hpp 22 May 2003 02:10:52 -0000 1.10 +++ RegularExpression.hpp 14 Aug 2003 02:57:27 -0000 1.11 @@ -190,16 +190,17 @@ ~Context(); inline const XMLCh* getString() const { return fString; } - void reset(const XMLCh* const string, const int start, - const int limit, const int noClosures); + void reset(const XMLCh* const string, const int stringLen, + const int start, const int limit, const int noClosures); bool nextCh(XMLInt32& ch, int& offset, const short direction); bool fInUse; bool fAdoptMatch; int fStart; int fLimit; - int fLength; + int fLength; // fLimit - fStart int fSize; + int fStringMaxLen; int* fOffsets; Match* fMatch; XMLCh* fString;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]