Skip to content
Snippets Groups Projects
Commit f0848765 authored by Tomáš Pecka's avatar Tomáš Pecka
Browse files

Algebraic Method: decrease memory consumption by reducing regexp trees on the...

Algebraic Method: decrease memory consumption by reducing regexp trees on the fly (side effect: speedup)
parent 0a5e72bf
No related branches found
No related tags found
No related merge requests found
......@@ -23,10 +23,6 @@ BrzozowskiAlgebraic::~BrzozowskiAlgebraic( void )
{
for( const auto & kv : m_eqFinal )
delete kv.second;
for( const auto & kv1 : m_eqTransition )
for( const auto & kv2 : kv1.second )
delete kv2.second;
}
 
void BrzozowskiAlgebraic::initEquations( void )
......@@ -58,6 +54,8 @@ void BrzozowskiAlgebraic::initEquations( void )
 
void BrzozowskiAlgebraic::eliminate( void )
{
RegExpOptimize opt;
for( auto itA = m_statesByDepth.rbegin( ); itA != m_statesByDepth.rend( ); itA ++ )
{
const State & a = * itA;
......@@ -77,12 +75,14 @@ void BrzozowskiAlgebraic::eliminate( void )
Concatenation* concat = new Concatenation( );
concat->getElements( ).push_back( loop->clone( ) );
concat->getElements( ).push_back( m_eqTransition[ a ][ b ] );
m_eqTransition[ a ][ b ] = concat;
m_eqTransition[ a ][ b ] = opt.optimize( concat );
delete concat;
}
Concatenation* concat = new Concatenation( );
concat->getElements( ).push_back( loop->clone( ) );
concat->getElements( ).push_back( m_eqFinal[ a ] );
m_eqFinal[ a ] = concat;
m_eqFinal[ a ] = opt.optimize( concat );
delete concat;
 
loop->setElement( NULL );
delete loop;
......@@ -105,7 +105,8 @@ void BrzozowskiAlgebraic::eliminate( void )
concat->getElements( ).push_back( m_eqTransition[ a ][ c ]->clone( ) );
alt->getElements( ).push_back( m_eqTransition[ b ][ c ] );
alt->getElements( ).push_back( concat );
m_eqTransition[ b ][ c ] = alt;
m_eqTransition[ b ][ c ] = opt.optimize( alt );
delete alt;
}
 
Alternation* alt = new Alternation( );
......@@ -114,8 +115,12 @@ void BrzozowskiAlgebraic::eliminate( void )
concat->getElements( ).push_back( m_eqFinal[ a ]->clone( ) );
alt->getElements( ).push_back( m_eqFinal[ b ] );
alt->getElements( ).push_back( concat );
m_eqFinal[ b ] = alt;
m_eqFinal[ b ] = opt.optimize( alt );
delete alt;
}
for( const auto & kv : m_eqTransition[ a ] )
delete kv.second;
}
}
 
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment