You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2001/08/16 23:52:40 UTC

cvs commit: xml-xerces/c/src/validators/common DFAContentModel.cpp

peiyongz    01/08/16 14:52:40

  Modified:    c/src/validators/common DFAContentModel.cpp
  Log:
  stateTable created to optimize the identification of new state created.
  
  Revision  Changes    Path
  1.18      +29 -7     xml-xerces/c/src/validators/common/DFAContentModel.cpp
  
  Index: DFAContentModel.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/common/DFAContentModel.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DFAContentModel.cpp	2001/07/31 17:45:25	1.17
  +++ DFAContentModel.cpp	2001/08/16 21:52:40	1.18
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: DFAContentModel.cpp,v $
  + * Revision 1.18  2001/08/16 21:52:40  peiyongz
  + * stateTable created to optimize the identification of new state created.
  + *
    * Revision 1.17  2001/07/31 17:45:25  peiyongz
    * Fix: memory leak in postTreeBuildInit()
    *
  @@ -155,7 +158,8 @@
   #include <validators/common/Grammar.hpp>
   #include <validators/schema/SubstitutionGroupComparator.hpp>
   #include <util/RefHashTableOf.hpp>
  -
  +#include <util/HashCMStateSet.hpp>
  +#include <util/XMLInteger.hpp>
   
   // ---------------------------------------------------------------------------
   //  DFAContentModel: Constructors and Destructor
  @@ -655,12 +659,16 @@
       statesToDo[curState] = setT;
       curState++;
   
  -    //
  -    // RefHashTableOf<unsigned int> stateTable(curArraySize, false);
  -    // In XML4J, a hash table is created, with CMStateSet as key and
  -    // the related index value as data.
  -    // We don't do HashTable searching here 'cause the performance
  -    // gain is NOT so clear.
  +    // 
  +    // the stateTable is an auxiliary means to fast
  +    // identification of new state created (instead
  +    // of squential loop statesToDo to find out), 
  +    // while the role that statesToDo plays remain unchanged.
  +    // 
  +    // TODO: in the future, we may change the 29 to something
  +    //       derived from curArraySize.
  +    RefHashTableOf<XMLInteger> *stateTable = new RefHashTableOf<XMLInteger>(curArraySize, true, new HashCMStateSet());
  +    //stateTable->put((CMStateSet*)setT, new XMLInteger(0));
   
       //
       //  Ok, almost done with the algorithm from hell... We now enter the
  @@ -756,13 +764,19 @@
                   //  Search the 'states to do' list to see if this new
                   //  state set is already in there.
                   //
  +
  +                /***
                   unsigned int stateIndex = 0;
                   for (; stateIndex < curState; stateIndex++)
                   {
                       if (*statesToDo[stateIndex] == *newSet)
                           break;
                   }
  +                ***/
   
  +                XMLInteger *stateObj = (XMLInteger*) (stateTable->get(newSet));
  +                unsigned int stateIndex = (stateObj == 0 ? curState : stateObj->intValue());
  +
                   // If we did not find it, then add it
                   if (stateIndex == curState)
                   {
  @@ -773,6 +787,7 @@
                       //
                       statesToDo[curState] = newSet;
                       fTransTable[curState] = makeDefStateList();
  +                    stateTable->put(newSet, new XMLInteger(curState));
   
                       // We now have a new state to do so bump the count
                       curState++;
  @@ -862,6 +877,13 @@
       for (index = 0; index < fLeafCount; index++)
           delete fFollowList[index];
       delete [] fFollowList;
  +
  +    //
  +    // removeAll() will delete all data, XMLInteger,
  +    // while the keys are to be deleted by the 
  +    // deletion of statesToDo.
  +    //
  +    delete stateTable;
   
       for (index = 0; index < curState; index++)
           delete (CMStateSet*)statesToDo[index];
  
  
  

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