Skip to content
Snippets Groups Projects
Commit d80e2c16 authored by Jan Travnicek's avatar Jan Travnicek
Browse files

fix V2 optimisation of regexps

parent a7435a4b
No related branches found
No related tags found
1 merge request!83fix V2 optimisation of regexps
Pipeline #35855 passed
......@@ -471,17 +471,19 @@ bool RegExpOptimize::Unbounded < SymbolType >::V2( UnboundedRegExpAlternation <
*/
 
ext::vector < const UnboundedRegExpElement < SymbolType > * > iterElements;
// cache iter elements because of operator invalidation after erase
// cache iter elements because of operator invalidation after erase only cache nodes that are not iterations (the nodes omitted may only come from situation like x** where the double iteration wil get optimized out elsewhere).
for( const UnboundedRegExpElement < SymbolType > & n : node.getElements ( ) ) {
const UnboundedRegExpIteration < SymbolType > * iter = dynamic_cast < const UnboundedRegExpIteration < SymbolType > * > ( & n );
if( iter ) {
const UnboundedRegExpAlternation < SymbolType > * inner = dynamic_cast < const UnboundedRegExpAlternation < SymbolType > * > ( & iter->getChild ( ) );
if ( inner )
for ( const UnboundedRegExpElement < SymbolType > & innerElement : inner->getElements ( ) )
iterElements.push_back ( & innerElement );
for ( const UnboundedRegExpElement < SymbolType > & innerElement : inner->getElements ( ) ) {
if ( ! dynamic_cast < const UnboundedRegExpIteration < SymbolType > * > ( & innerElement ) )
iterElements.push_back ( & innerElement );
}
else
iterElements.push_back ( & iter->getChild ( ) );
if ( ! dynamic_cast < const UnboundedRegExpIteration < SymbolType > * > ( & iter->getChild ( ) ) )
iterElements.push_back ( & iter->getChild ( ) );
}
}
 
......
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