From d73247a2dfa25794320047adbd17edf46bb17197 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 19 Jul 2016 13:56:54 +0200 Subject: [PATCH] better constr. of temp regexps in optimisations --- .../simplify/RegExpOptimizeUnboundedPart.cxx | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.cxx b/alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.cxx index 0de8982278..75c1235a44 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 ); -- GitLab