Skip to content
Snippets Groups Projects
Commit d73247a2 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

better constr. of temp regexps in optimisations

parent 13e729a8
No related branches found
No related tags found
No related merge requests found
......@@ -628,26 +628,18 @@ bool RegExpOptimize::V5( UnboundedRegExpAlternation & node ) {
tmpAY.pushBackChild( std::smart_ptr < UnboundedRegExpElement > ( regexpA ) );
tmpAY.pushBackChild( std::smart_ptr < UnboundedRegExpElement > ( regexpY ) );
UnboundedRegExpElement * regexpAY = optimizeInner( tmpAY );
regexpA = tmpAY.getChildren()[0].release();
regexpY = tmpAY.getChildren()[1].release();
 
auto iterAY = find_if( node.getChildren().begin( ), node.getChildren().end( ), [ regexpAY ] ( const std::smart_ptr < UnboundedRegExpElement > & a ) -> bool{ return *a == *regexpAY; } );
delete regexpAY;
if( iterAY == node.getChildren().end( ) ) {
++ itC;
delete regexpA;
delete regexpY;
 
continue;
}
 
UnboundedRegExpConcatenation tmpAltered;
tmpAltered.pushBackChild( std::smart_ptr < UnboundedRegExpElement > ( regexpA ) );
tmpAltered.pushBackChild( * itC );
tmpAltered.pushBackChild( std::smart_ptr < UnboundedRegExpElement > ( regexpY ) );
UnboundedRegExpElement * regexpAltered = optimizeInner( tmpAltered );
tmpAY.insert( tmpAY.getChildren ( ).begin ( ) + 1, * itC );
 
node.setChild( std::smart_ptr < UnboundedRegExpElement > ( regexpAltered ), itA );
node.setChild( std::smart_ptr < UnboundedRegExpElement > ( optimizeInner( tmpAY ) ), itA );
 
itA = node.getChildren().erase( iterAY );
 
......@@ -743,26 +735,18 @@ bool RegExpOptimize::V6( UnboundedRegExpAlternation & node ) {
tmpAY.pushBackChild( std::smart_ptr < UnboundedRegExpElement > ( regexpA ) );
tmpAY.pushBackChild( std::smart_ptr < UnboundedRegExpElement > ( regexpY ) );
UnboundedRegExpElement * regexpAY = optimizeInner( tmpAY );
regexpA = tmpAY.getChildren()[0].release();
regexpY = tmpAY.getChildren()[1].release();
 
auto iterAY = find_if( node.getChildren().begin( ), node.getChildren().end( ), [ regexpAY ] ( const std::smart_ptr < UnboundedRegExpElement > & a ) -> bool{ return *a == *regexpAY; } );
delete regexpAY;
if( iterAY == node.getChildren().end( ) ) {
++ itC;
 
delete regexpA;
delete regexpY;
continue;
}
 
UnboundedRegExpConcatenation tmpAltered;
tmpAltered.pushBackChild( std::smart_ptr < UnboundedRegExpElement > ( regexpA ) );
tmpAltered.pushBackChild( * itC );
tmpAltered.pushBackChild( std::smart_ptr < UnboundedRegExpElement > ( regexpY ) );
UnboundedRegExpElement * regexpAltered = optimizeInner( tmpAltered );
tmpAY.insert( tmpAY.getChildren ( ).begin ( ) + 1, * itC );
 
node.setChild( std::smart_ptr < UnboundedRegExpElement > ( regexpAltered ), itA );
node.setChild( std::smart_ptr < UnboundedRegExpElement > ( optimizeInner( tmpAY ) ), itA );
 
itA = node.getChildren().erase( iterAY );
 
......
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