You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2003/01/09 16:28:09 UTC

cvs commit: xml-xerces/c/src/xercesc/internal XMLScanner.cpp

tng         2003/01/09 07:28:09

  Modified:    c/src/xercesc/internal XMLScanner.cpp
  Log:
  Performance: construct message loader only when required.
  
  Revision  Changes    Path
  1.37      +21 -15    xml-xerces/c/src/xercesc/internal/XMLScanner.cpp
  
  Index: XMLScanner.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.cpp,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- XMLScanner.cpp	6 Jan 2003 19:44:57 -0000	1.36
  +++ XMLScanner.cpp	9 Jan 2003 15:28:08 -0000	1.37
  @@ -144,6 +144,23 @@
       return *sScannerMutex;
   }
   
  +static XMLMsgLoader& gScannerMsgLoader()
  +{
  +    XMLMutexLock lockInit(&gScannerMutex());
  +
  +    // If we haven't loaded our message yet, then do that
  +    if (!gMsgLoader)
  +    {
  +        gMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLErrDomain);
  +        if (!gMsgLoader)
  +            XMLPlatformUtils::panic(XMLPlatformUtils::Panic_CantLoadMsgDomain);
  +
  +        // Register this object to be cleaned up at termination
  +        cleanupMsgLoader.registerCleanup(XMLScanner::reinitMsgLoader);
  +    }
  +
  +    return *gMsgLoader;
  +}
   
   // ---------------------------------------------------------------------------
   //  XMLScanner: Constructors and Destructor
  @@ -655,17 +672,6 @@
       {
           XMLMutexLock lockInit(&gScannerMutex());
   
  -        // If we haven't loaded our message yet, then do that
  -        if (!gMsgLoader)
  -        {
  -            gMsgLoader = XMLPlatformUtils::loadMsgSet(XMLUni::fgXMLErrDomain);
  -            if (!gMsgLoader)
  -                XMLPlatformUtils::panic(XMLPlatformUtils::Panic_CantLoadMsgDomain);
  -
  -            // Register this object to be cleaned up at termination
  -			cleanupMsgLoader.registerCleanup(reinitMsgLoader);
  -        }
  -
           // And assign ourselves the next available scanner id
           fScannerId = ++gScannerId;
       }
  @@ -711,7 +717,7 @@
           const unsigned int msgSize = 1023;
           XMLCh errText[msgSize + 1];
   
  -        if (!gMsgLoader->loadMsg(toEmit, errText, msgSize))
  +        if (!gScannerMsgLoader().loadMsg(toEmit, errText, msgSize))
           {
                   // <TBD> Probably should load a default msg here
           }
  @@ -758,7 +764,7 @@
           const unsigned int maxChars = 2047;
           XMLCh errText[maxChars + 1];
   
  -        if (!gMsgLoader->loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4))
  +        if (!gScannerMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4))
           {
                   // <TBD> Should probably load a default message here
           }
  @@ -805,7 +811,7 @@
           const unsigned int maxChars = 2047;
           XMLCh errText[maxChars + 1];
   
  -        if (!gMsgLoader->loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4))
  +        if (!gScannerMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4))
           {
                   // <TBD> Should probably load a default message here
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org