diff --git a/alib2algo/src/tree/properties/ReversedBadCharacterShiftTable.h b/alib2algo/src/tree/properties/ReversedBadCharacterShiftTable.h index ad2e930901242871fac187395d437633b7d1a282..4cf4a3d779f25c3bcb72f1ec849f9e05ca40e9c5 100644 --- a/alib2algo/src/tree/properties/ReversedBadCharacterShiftTable.h +++ b/alib2algo/src/tree/properties/ReversedBadCharacterShiftTable.h @@ -65,8 +65,7 @@ ext::map < common::ranked_symbol < SymbolType, RankType >, size_t > ReversedBadC // of the first symbol representing the variable's bar size_t firstSBarOffset = FirstVariableOffsetFront::offset ( pattern ) + 1; - // limit the shift by occurrence of the last variable - + // limit the shift by occurrence of the last variable's bar for ( const common::ranked_symbol < SymbolType, RankType > & symbol : alphabet ) { if ( ( symbol == pattern.getSubtreeWildcard ( ) ) || ( pattern.getNonlinearVariables ( ).count ( symbol ) ) || ( symbol == pattern.getVariablesBar ( ) ) ) continue; @@ -118,9 +117,10 @@ ext::map < common::ranked_symbol < SymbolType, RankType >, size_t > ReversedBadC } // find the distance between the beginning of the pattern and the index - // of the first symbol representing the variable's bar + // of the first symbol representing the variable size_t firstSOffset = FirstVariableOffsetFront::offset ( pattern ); + // handle situation when the pattern is just S if ( firstSOffset == 0 ) firstSOffset = 1; // limit the shift by occurrence of the last variable