Changeset 186 for trunk/Forms


Ignore:
Timestamp:
Jul 11, 2018, 3:34:11 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Faster substring searching with PosFromIndex function without unnecessary string copying.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormCheck.pas

    r185 r186  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ExtCtrls, ComCtrls, UAcronym, URegistry, Registry;
     9  ExtCtrls, ComCtrls, UAcronym, URegistry, Registry, UCommon;
    1010
    1111type
     
    4949    function SearchLine(Lines: TStrings; Text: string; Start: Integer = 0): Integer;
    5050    function SearchLineReverse(Lines: TStrings; Text: string; Start: Integer = -1): Integer;
    51     function PosFromIndex(SubStr: string; Text: string; StartIndex: Integer): Integer;
    52     function PosFromIndexReverse(SubStr: string; Text: string; StartIndex: Integer): Integer;
    5351    procedure FindInSummary;
    5452    procedure FindInContent;
     
    173171    else Result := Start;
    174172  while (Result >= 0) and (Pos(Text, Lines[Result]) = 0) do Dec(Result);
    175 end;
    176 
    177 function TFormCheck.PosFromIndex(SubStr: string; Text: string;
    178   StartIndex: Integer): Integer;
    179 begin
    180   Delete(Text, 1, StartIndex);
    181   Result := Pos(SubStr, Text);
    182   if Result <> 0 then Result := Result + StartIndex;
    183 end;
    184 
    185 function TFormCheck.PosFromIndexReverse(SubStr: string; Text: string;
    186   StartIndex: Integer): Integer;
    187 begin
    188   Delete(Text, StartIndex + 1, Length(Text));
    189   Result := LastDelimiter(SubStr, Text);
    190173end;
    191174
Note: See TracChangeset for help on using the changeset viewer.