anchor.diff:   inherited Destroy;
   end;
   
  -function TFLREThreadLocalStorageInstance.GetSatisfyFlags(const Position:longint):longword;
  -var PreviousPosition:longint;
  -    PreviousChar,CurrentChar:longword;
  -begin
  - result:=0;
  - if rfUTF8 in Instance.Flags then begin
  -  PreviousPosition:=Position;
  -  UTF8PtrDec(Input,InputLength,PreviousPosition);
  -  if (PreviousPosition>=0) and (PreviousPosition<=InputLength) then begin
  -   PreviousChar:=UTF8PtrCodeUnitGetCharFallback(Input,InputLength,PreviousPosition);
  -  end else begin
  -   PreviousChar:=0;
  -  end;
  -  if (Position>=0) and (Position<InputLength) then begin
  -   CurrentChar:=UTF8PtrCodeUnitGetCharFallback(Input,InputLength,Position);
  -  end else begin
  -   CurrentChar:=0;
  -  end;
  - end else begin
  -  PreviousPosition:=Position-1;
  -  if (PreviousPosition>=0) and (PreviousPosition<=InputLength) then begin
  -   PreviousChar:=byte(ansichar(Input[PreviousPosition]));
  -  end else begin
  -   PreviousChar:=0;
  -  end;
  -  if (Position>=0) and (Position<InputLength) then begin
  -   CurrentChar:=byte(ansichar(Input[Position]));
  -  end else begin
  -   CurrentChar:=0;
  -  end;
  - end;
  - if Position<=0 then begin
  -  result:=result or (sfEmptyBeginText or sfEmptyBeginLine);
  - end else begin
  -  case PreviousChar of
  -   $0a,$0d,$85,$2028,$2029:begin
  -    result:=result or sfEmptyBeginLine;
  -   end;
  -  end;
  - end;
  - if Position>=(InputLength-1) then begin
  -  result:=result or (sfEmptyEndText or sfEmptyEndLine);
  - end else begin
  -  case CurrentChar of
  -   $0a,$0d,$85,$2028,$2029:begin
  -    result:=result or sfEmptyEndLine;
  -   end;
  -  end;
  - end;
  - if InputLength>0 then begin
  -  if Position=0 then begin
  -   if Instance.IsWordChar(CurrentChar) then begin
  -    result:=result or sfEmptyWordBoundary;
  -   end;
  -  end else if Position>=InputLength then begin
  -   if Instance.IsWordChar(PreviousChar) then begin
  -    result:=result or sfEmptyWordBoundary;
  -   end;
  -  end else if Instance.IsWordChar(PreviousChar)<>Instance.IsWordChar(CurrentChar) then begin
  -   result:=result or sfEmptyWordBoundary;
  -  end;
  - end;
  - if (result and sfEmptyWordBoundary)=0 then begin
  -  result:=result or sfEmptyNonWordBoundary;
  - end;
  -end;
  -
  -function TFLREThreadLocalStorageInstance.GetDFAStartFlags(const Position:longint):longword;
  -begin
  - result:=GetSatisfyFlags(Position);
  -end;
  -
  -function TFLREThreadLocalStorageInstance.LookAssertion(const Position,WhichLookAssertionString:longint;const LookBehind,Negative:boolean):boolean;
  -var Index,LookAssertionStringLength,BasePosition:longint;
  -    LookAssertionString:ansistring;
  -begin
  - LookAssertionString:=Instance.LookAssertionStrings[WhichLookAssertionString];
  - LookAssertionStringLength:=length(LookAssertionString);
  - if LookBehind then begin
  -  if Position>=LookAssertionStringLength then begin
  -   result:=true;
  -   for Index:=0 to LookAssertionStringLength-1 do begin
  -    if Input[Position-Index]<>LookAssertionString[LookAssertionStringLength-Index] then begin
  -     result:=false;
  -     break;
  -    end;
  -   end;
  -  end else begin
  -   result:=false;
  -  end;
  - end else begin
  -  if (Position+LookAssertionStringLength)<=InputLength then begin
  -   result:=true;
  -   BasePosition:=Position;
  -   if rfUTF8 in Instance.Flags then begin
  -    UTF8PtrSafeInc(Input,InputLength,BasePosition);
  -    dec(BasePosition);
  -   end;
  -   for Index:=1 to LookAssertionStringLength do begin
  -    if Input[BasePosition+Index]<>LookAssertionString[Index] then begin
  -     result:=false;
  -     break;
  -    end;
  -   end;
  -  end else begin
  -   result:=false;
  -  end;
  - end;
  - result:=result xor Negative;
  -end;
  -
  -function TFLREThreadLocalStorageInstance.BackReferenceAssertion(const CaptureStart,CaptureEnd,BackReferenceStart,BackReferenceEnd:longint;const IgnoreCase:boolean):boolean;
  -var CapturePosition,BackReferencePosition:longint;
  -begin
  - result:=false;
  - if (CaptureStart>=0) and (CaptureEnd>0) and (BackReferenceStart>=0) and (BackReferenceEnd>0) then begin
  -  if IgnoreCase then begin
  -   if rfUTF8 in Instance.Flags then begin
  -    result:=true;
  -    CapturePosition:=CaptureStart;
  -    BackReferencePosition:=BackReferenceStart;
  -    while (CapturePosition<CaptureEnd) and (BackReferencePosition<BackReferenceEnd) do begin
  -     if UnicodeToLower(UTF8PtrCodeUnitGetCharAndIncFallback(Input,InputLength,CapturePosition))<>UnicodeToLower(UTF8PtrCodeUnitGetCharAndIncFallback(Input,InputLength,BackReferencePosition)) then begin
  -      result:=false;
  -      exit;
  -     end;
  -    end;
  -   end else begin
  -    if (CaptureEnd-CaptureStart)=(BackReferenceEnd-BackReferenceStart) then begin
  -     result:=true;
  -     CapturePosition:=CaptureStart;
  -     BackReferencePosition:=BackReferenceStart;
  -     while (CapturePosition<CaptureEnd) and (BackReferencePosition<BackReferenceEnd) do begin
  -      if UnicodeToLower(byte(ansichar(Input[CapturePosition])))<>UnicodeToLower(byte(ansichar(Input[BackReferencePosition]))) then begin
  -       result:=false;
  -       exit;
  -      end;
  -      inc(CapturePosition);
  -      inc(BackReferencePosition);
  -     end;
  -    end;
  -   end;
  -  end else begin
  -   if (CaptureEnd-CaptureStart)=(BackReferenceEnd-BackReferenceStart) then begin
  -    result:=true;
  -    CapturePosition:=CaptureStart;
  -    BackReferencePosition:=BackReferenceStart;
  -    while (CapturePosition<CaptureEnd) and (BackReferencePosition<BackReferenceEnd) do begin
  -     if Input[CapturePosition]<>Input[BackReferencePosition] then begin
  -      result:=false;
  -      exit;
  -     end;
  -     inc(CapturePosition);
  -     inc(BackReferencePosition);
  -    end;
  -   end;
  -  end;
  - end;
  -end;
  -
  -function TFLREThreadLocalStorageInstance.ParallelNFAStateAllocate(const Count:longint;const SubMatchesBitmap:longword):PFLREParallelNFAState; {$ifdef caninline}inline;{$endif}
  -begin
  - if assigned(FreeParallelNFAStates) then begin
  -  result:=FreeParallelNFAStates;
  -  FreeParallelNFAStates:=result^.Next;
  +function TFLREParallelNFA.StateAllocate(const Count:longint;const SubMatchesBitmap:longword):PFLREParallelNFAState; {$ifdef caninline}inline;{$endif}
  +begin
  + if assigned(FreeStates) then begin
  +  result:=FreeStates;
  +  FreeStates:=result^.Next;
    end else begin
     GetMem(result,SizeOf(TFLREParallelNFAState));
     FillChar(result^,SizeOf(TFLREParallelNFAState),#0);
     SetLength(result^.SubMatches,Instance.CountSubMatches);
  -  AllParallelNFAStates.Add(result);
  +  AllStates.Add(result);
    end;
    result^.ReferenceCounter:=1;
    result^.Count:=Count;
    result^.SubMatchesBitmap:=SubMatchesBitmap;
   end;
   
  -function TFLREThreadLocalStorageInstance.ParallelNFAStateAcquire(const State:PFLREParallelNFAState):PFLREParallelNFAState; {$ifdef caninline}inline;{$endif}
  +function TFLREParallelNFA.StateAcquire(const State:PFLREParallelNFAState):PFLREParallelNFAState; {$ifdef caninline}inline;{$endif}
   begin
    inc(State^.ReferenceCounter);
    result:=State;
   end;
   
  -procedure TFLREThreadLocalStorageInstance.ParallelNFAStateRelease(const State:PFLREParallelNFAState); {$ifdef caninline}inline;{$endif}
  +procedure TFLREParallelNFA.StateRelease(const State:PFLREParallelNFAState); {$ifdef caninline}inline;{$endif}
   begin
    dec(State^.ReferenceCounter);
    if State^.ReferenceCounter=0 then begin
  -  State^.Next:=FreeParallelNFAStates;
  -  FreeParallelNFAStates:=State;
  - end;
  -end;
  -
  -function TFLREThreadLocalStorageInstance.ParallelNFAStateUpdate(const State:PFLREParallelNFAState;const Index,Position:longint):PFLREParallelNFAState; {$ifdef caninline}inline;{$endif}
  +  State^.Next:=FreeStates;
  +  FreeStates:=State;
  + end;
  +end;
  +
  +function TFLREParallelNFA.StateUpdate(const State:PFLREParallelNFAState;const Index,Position:longint):PFLREParallelNFAState; {$ifdef caninline}inline;{$endif}
   var Counter:longint;
       SubMatchesBitmap:longword;
   begin
    result:=State;
    if result^.ReferenceCounter>1 then begin
  -  result:=ParallelNFAStateAllocate(State^.Count,State^.SubMatchesBitmap);
  +  result:=StateAllocate(State^.Count,State^.SubMatchesBitmap);
   {$ifdef cpu386}
     asm
      push ebx
  
positive.code:    end;
    end;
   end;(**)
   if OnePassNFAReady and not UnanchoredStart then begin
    result:=ThreadLocalStorageInstance.SearchMatchOnePassNFA(Captures,StartPosition,UntilExcludingPosition);
   end else begin
    if BitStateNFAReady then begin
     case ThreadLocalStorageInstance.SearchMatchBitStateNFA(Captures,StartPosition,UntilExcludingPosition,UnanchoredStart) of
      BitStateNFAFail:begin
       result:=false;
  
negative.code:  end;
  end;
  
  constructor TFLREParallelNFA.Create(const AThreadLocalStorageInstance:TFLREThreadLocalStorageInstance);
  var Index:longint;
  begin
   inherited Create;
  
   ThreadLocalStorageInstance:=AThreadLocalStorageInstance;
  
   Instance:=ThreadLocalStorageInstance.Instance;
  
   SearchLongest:=ThreadLocalStorageInstance.SearchLongest;
  
   Generation:=0;
  
   InstructionGenerations:=nil;
   SetLength(InstructionGenerations,Instance.CountForwardInstructions);
   for Index:=0 to length(InstructionGenerations)-1 do begin
    InstructionGenerations[Index]:=-1;
   end;
  
   ParallelNFAThreadLists[0].Threads:=nil;
   ParallelNFAThreadLists[1].Threads:=nil;
   SetLength(ParallelNFAThreadLists[0].Threads,Instance.CountForwardInstructions*2);
   SetLength(ParallelNFAThreadLists[1].Threads,Instance.CountForwardInstructions*2);
  
   ParallelNFAStack:=nil;
   SetLength(ParallelNFAStack,Instance.CountForwardInstructions*2);
  
   FreeStates:=nil;
   AllStates:=TList.Create;
  
  end;
  
  destructor TFLREParallelNFA.Destroy;
  var State:PFLREParallelNFAState;
  begin
  
   while assigned(FreeStates) do begin
    State:=FreeStates;
    FreeStates:=FreeStates^.Next;
    SetLength(State^.SubMatches,0);
    Finalize(State^);
    FreeMem(State);
   end;
   FreeStates:=nil;
  
   FreeAndNil(AllStates);
  
   SetLength(InstructionGenerations,0);
  
   SetLength(ParallelNFAThreadLists[0].Threads,0);
   SetLength(ParallelNFAThreadLists[1].Threads,0);
  