anchor.diff:   if DoFastDFA then begin
     WorkQueues[0]:=nil;
     WorkQueues[1]:=nil;
  +  if Reversed then begin
  +   SearchMatch:=SearchMatchFastReversed;
  +  end else begin
  +   SearchMatch:=SearchMatchFast;
  +  end;
    end else begin
     if NeedMark then begin
      WorkQueues[0]:=TFLREDFAWorkQueue.Create(CountInstructions*3);
  
positive.code:        procedure FastAddInstructionThread(const State:PFLREDFAState;Instruction:PFLREInstruction);
         function FastProcessNextState(State:PFLREDFAState;const CurrentChar:ansichar;const Reversed:boolean):PFLREDFAState;
         function SearchMatchFast(const StartPosition,UntilExcludingPosition:longint;out MatchEnd:longint;const UnanchoredStart:boolean):longint;
         function SearchMatchFastReversed(const StartPosition,UntilIncludingPosition:longint;out MatchBegin:longint):longint;
  
         function WorkQueueToCachedState(const WorkQueue:TFLREDFAWorkQueue;Flags:longword):PFLREDFAState;
         procedure StateToWorkQueue(const DFAState:PFLREDFAState;const WorkQueue:TFLREDFAWorkQueue);
  
negative.code:     Instruction:PFLREInstruction;
  begin
  
   result:=DFAFail;
  
   State:=InitializeStartState(StartPosition,UnanchoredStart);
  
   LocalInput:=ThreadLocalStorageInstance.Input;
   LocalInputLength:=ThreadLocalStorageInstance.InputLength;
  
   LocalByteMap:=@ByteMap;
  
   if assigned(State) and ((State^.Flags and sfDFAMatchWins)<>0) then begin
    MatchEnd:=StartPosition-1;
    result:=DFAMatch;
   end;
  
   for Position:=StartPosition to UntilExcludingPosition-1 do begin
    CurrentChar:=byte(ansichar(LocalInput[Position]));
    LastState:=State;
    State:=State^.NextStates[LocalByteMap^[CurrentChar]];
    if not assigned(State) then begin
     State:=RunStateOnByte(LastState,Position,CurrentChar);
     if not assigned(State) then begin
      result:=DFAError;
      exit;
     end;
    end;
    if (State^.Flags and (sfDFAMatchWins or sfDFADead or sfDFAFullMatch))<>0 then begin
     if (State^.Flags and sfDFADead)<>0 then begin
      if result<>DFAMatch then begin
       result:=DFAFail;
      end;
      exit;
     end;
     if (State^.Flags and sfDFAFullMatch)<>0 then begin
      MatchEnd:=UntilExcludingPosition-1;
      result:=DFAMatch;
      exit;
     end;
     if (State^.Flags and sfDFAMatchWins)<>0 then begin
      MatchEnd:=Position-1;
      result:=DFAMatch;
     end;
    end;
   end;
  
   Position:=UntilExcludingPosition;
  
   if (Position>=0) and (Position<LocalInputLength) then begin
    CurrentChar:=byte(ansichar(LocalInput[Position]));
   end else begin
    CurrentChar:=256;
   end;
  
   LastState:=State;
   State:=State^.NextStates[LocalByteMap^[CurrentChar]];
   if not assigned(State) then begin
    State:=RunStateOnByte(LastState,Position,CurrentChar);
    if not assigned(State) then begin
     result:=DFAError;
     exit;
    end;
   end;
   if (State^.Flags and (sfDFAMatchWins or sfDFADead or sfDFAFullMatch))<>0 then begin
    if (State^.Flags and sfDFADead)<>0 then begin
     if result<>DFAMatch then begin
      result:=DFAFail;
     end;
     exit;
    end;
    if (State^.Flags and sfDFAFullMatch)<>0 then begin
     MatchEnd:=UntilExcludingPosition-1;
     result:=DFAMatch;
     exit;
    end;
    if (State^.Flags and sfDFAMatchWins)<>0 then begin
     MatchEnd:=Position-1;
     result:=DFAMatch;
  {    if MatchMode=mmMultiMatch then begin
      for Index:=0 to State^.CountInstructions-1 do begin
       Instruction:=State^.Instructions[Index];
       if assigned(Instruction) and ((Instruction^.IDandOpcode and $ff)=opMATCH) then begin
        if (Instruction.Value>=0) and (Instruction.Value<Instance.CountMultiSubMatches) then begin
         ThreadLocalStorageInstance.MultiSubMatches[Instruction.Value]:=Instruction.Value;
        end;
       end;
      end;
     end;{}
    end;
   end;
  
  end;
  
  function TFLREDFA.SearchMatchFullReversed(const StartPosition,UntilExcludingPosition:longint;out MatchEnd:longint;const UnanchoredStart:boolean):longint;
  var Position,LocalInputLength:longint;
      State,LastState:PFLREDFAState;
      LocalInput:pansichar;
      Flags,CurrentChar:longword;
      LocalByteMap:PFLREDFAByteMap;
      Instruction:PFLREInstruction;
  begin
  
   result:=DFAFail;
  
   State:=InitializeStartState(StartPosition,UnanchoredStart);
  
   LocalInput:=ThreadLocalStorageInstance.Input;
   LocalInputLength:=ThreadLocalStorageInstance.InputLength;
  
   LocalByteMap:=@ByteMap;
  
   if assigned(State) and ((State^.Flags and sfDFAMatchWins)<>0) then begin
    MatchEnd:=StartPosition+1;
    result:=DFAMatch;
   end;
  
   for Position:=StartPosition downto UntilExcludingPosition do begin
    CurrentChar:=byte(ansichar(LocalInput[Position]));
    LastState:=State;
    State:=State^.NextStates[LocalByteMap^[CurrentChar]];
    if not assigned(State) then begin
     State:=RunStateOnByte(LastState,Position,CurrentChar);
     if not assigned(State) then begin
      result:=DFAError;
      exit;
     end;
    end;
    if (State^.Flags and (sfDFAMatchWins or sfDFADead or sfDFAFullMatch))<>0 then begin
     if (State^.Flags and sfDFADead)<>0 then begin
      if result<>DFAMatch then begin
       result:=DFAFail;
      end;
      exit;
     end;
     if (State^.Flags and sfDFAFullMatch)<>0 then begin
      MatchEnd:=UntilExcludingPosition-1;
      result:=DFAMatch;
      exit;
     end;
     if (State^.Flags and sfDFAMatchWins)<>0 then begin
      MatchEnd:=Position+1;
      result:=DFAMatch;
     end;
    end;
   end;
  
   Position:=UntilExcludingPosition-1;
  
   if (Position>=0) and (Position<LocalInputLength) then begin
    CurrentChar:=byte(ansichar(LocalInput[Position]));
   end else begin
    CurrentChar:=256;
   end;
  
   LastState:=State;
   State:=State^.NextStates[LocalByteMap^[CurrentChar]];
   if not assigned(State) then begin
    State:=RunStateOnByte(LastState,Position,CurrentChar);
    if not assigned(State) then begin
     result:=DFAError;
     exit;
    end;
   end;
   if (State^.Flags and (sfDFAMatchWins or sfDFADead or sfDFAFullMatch))<>0 then begin
    if (State^.Flags and sfDFADead)<>0 then begin
     if result<>DFAMatch then begin
      result:=DFAFail;
     end;
     exit;
    end;
    if (State^.Flags and sfDFAFullMatch)<>0 then begin
     MatchEnd:=UntilExcludingPosition;
     result:=DFAMatch;
     exit;
    end;
    if (State^.Flags and sfDFAMatchWins)<>0 then begin
     MatchEnd:=Position+1;
     result:=DFAMatch;
    end;
   end;
  
  end;
  