diff --git a/alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.cxx b/alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.cxx index 0de8982278e1a8931c6a8d28c613e61220688c82..75c1235a44e6cde1ed5a2b7a12024840c4eb4ec7 100644 --- a/alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.cxx +++ b/alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.cxx @@ -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 );