Changeset 20 for trunk/Compiler/Analyze


Ignore:
Timestamp:
Nov 9, 2010, 12:21:56 PM (14 years ago)
Author:
george
Message:
  • Modified: Tokenizer was using slow Text property of TStringList. Replaced by fast native string variable.
Location:
trunk/Compiler/Analyze
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/Analyze/UAnalyzer.pas

    r12 r20  
    2929  end;
    3030
    31   TGetSourceEvent = function (Name: string; Source: TStringList): Boolean of object;
     31  TGetSourceEvent = function (Name: string; var SourceCode: string): Boolean of object;
    3232
    3333  { TAnalyzer }
     
    5151    CodeStreamPosition: Integer;
    5252    CodePosition: TPoint;
    53     SourceCodeText: TStringList;
     53    SourceCode: string;
    5454    Tokens: TObjectList; // TObjectList<TToken>
    5555    TokenIndex: Integer;
     
    225225  Tokens.Clear;
    226226  TokenIndex := 0;
    227   while CodeStreamPosition < Length(SourceCodeText.Text) do begin
     227  while CodeStreamPosition < Length(SourceCode) do begin
    228228    NewToken := TToken.Create;
    229229    GetNextToken;
     
    255255  FNextTokenType := ttNone;
    256256  FParserState := psNone;
    257   with SourceCodeText do
     257
    258258    while True do begin
    259       if CodeStreamPosition < Length(Text) then begin
    260         CurrentChar := Text[CodeStreamPosition];
     259      if CodeStreamPosition < Length(SourceCode) then begin
     260        CurrentChar := SourceCode[CodeStreamPosition];
    261261      end else begin
    262262        FNextToken := '';
  • trunk/Compiler/Analyze/UAnalyzerPascal.pas

    r19 r20  
    9191  try
    9292    Parser := TAnalyzerPascal.Create;
    93     Parser.SourceCodeText := TStringList.Create;
    9493    Parser.OnDebugLog := OnDebugLog;
    9594    Parser.ProgramCode := ProgramCode;
    9695    Parser.OnGetSource := OnGetSource;
    9796    if Assigned(OnGetSource) then begin
    98       if OnGetSource(Name, Parser.SourceCodeText) then begin
     97      if OnGetSource(Name, Parser.SourceCode) then begin
    9998        Parser.Process;
    10099        Parser.FileName := Name;
     
    107106    end else Result := False;
    108107  finally
    109     Parser.SourceCodeText.Free;
    110108    Parser.Free;
    111109  end;
     
    560558  NewType: TType;
    561559begin
     560  Log('ParseCommonBlockInterface');
    562561  with SourceCode do begin
    563562    while (NextToken <> 'implementation') and (NextTokenType <> ttEndOfFile) do begin
Note: See TracChangeset for help on using the changeset viewer.