@@ -180,6 +180,7 @@ friend class AllocReporter;
180180
181181 static AllocCounter ac;
182182 static AllocCounter acMatches;
183+ static AllocCounter acNativeMatches;
183184
184185protected:
185186
@@ -457,6 +458,10 @@ Node* State::getResult(INT iStartNt) const
457458
458459AllocCounter Column::ac;
459460AllocCounter Column::acMatches;
461+ AllocCounter Column::acNativeMatches;
462+
463+ // Counter of native matching tables allocated by setMatchingTable()
464+ static AllocCounter acMatchingTables;
460465
461466Column::Column (Parser* pParser, UINT nToken)
462467 : m_pParser(pParser),
@@ -626,6 +631,7 @@ BOOL Column::matches(UINT nHandle, UINT nTerminal) const
626631 (((const TokenRec*)pRec)->nCountFlags & (TKF_FAST | TKF_EMPTY_WORD )) != 0 );
627632 if (bNative) {
628633 b = Parser::evalMatch (pSpec, pRec, this ->m_pParser ->getMasks ());
634+ Column::acNativeMatches++; // Count native match evaluations
629635 if (this ->m_pParser ->parityMode ()) {
630636 // Parity mode: also obtain the Python result; count any
631637 // discrepancy and return the Python (canonical) answer
@@ -1076,8 +1082,10 @@ Parser::Parser(Grammar* p, MatchingFunc pMatchingFunc, AllocFunc pAllocFunc)
10761082
10771083Parser::~Parser (void )
10781084{
1079- if (this ->m_pSpecs )
1085+ if (this ->m_pSpecs ) {
10801086 delete [] this ->m_pSpecs ;
1087+ acMatchingTables--;
1088+ }
10811089}
10821090
10831091void Parser::setMatchingTable (const BYTE * pSpecs, UINT nSpecs,
@@ -1089,6 +1097,7 @@ void Parser::setMatchingTable(const BYTE* pSpecs, UINT nSpecs,
10891097 if (this ->m_pSpecs ) {
10901098 delete [] this ->m_pSpecs ;
10911099 this ->m_pSpecs = NULL ;
1100+ acMatchingTables--;
10921101 }
10931102 this ->m_nSpecs = 0 ;
10941103 this ->m_pMeaningsFunc = NULL ;
@@ -1098,6 +1107,7 @@ void Parser::setMatchingTable(const BYTE* pSpecs, UINT nSpecs,
10981107 if (!pSpecs || !nSpecs || !fpMeanings || !pMasks)
10991108 return ;
11001109 this ->m_pSpecs = new TerminalSpec[nSpecs];
1110+ acMatchingTables++;
11011111 memcpy (this ->m_pSpecs , pSpecs, nSpecs * sizeof (TerminalSpec));
11021112 this ->m_nSpecs = nSpecs;
11031113 memcpy (&this ->m_masks , pMasks, sizeof (MatchMasks));
@@ -1571,6 +1581,8 @@ void AllocReporter::report(void) const
15711581 printf (" HNodes : %6d %8d\n " , HNode::ac.getBalance (), HNode::ac.numAllocs ());
15721582 printf (" NodeDict lookups: %6s %8d\n " , " " , NodeDict::acLookups.numAllocs ());
15731583 printf (" Matching calls : %6s %8d\n " , " " , Column::acMatches.numAllocs ());
1584+ printf (" ...thereof native: %5s %8d\n " , " " , Column::acNativeMatches.numAllocs ());
1585+ printf (" MatchingTables : %6d %8d\n " , acMatchingTables.getBalance (), acMatchingTables.numAllocs ());
15741586 fflush (stdout); // !!! Debugging
15751587}
15761588
0 commit comments