Skip to content

Commit 7e5c08f

Browse files
committed
Rework parser define/ifdef conditional logic, no linked list and less allocations
1 parent 43a70ab commit 7e5c08f

4 files changed

Lines changed: 141 additions & 227 deletions

File tree

Source/ide/codetools/simba.ide_codetools_debug.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ procedure DebugCache;
121121
TreeView.AddNode(n, 'Max Stack Depth: ' + IntToStr(Parser.Stack.Max), IMG_INFO);
122122
TreeView.AddNode(n, 'Ref Count: ' + IntToStr(TCodetoolsInclude(Parser).RefCount), IMG_INFO);
123123
TreeView.AddNode(n, 'Last Used: ' + IntToStr(TCodetoolsInclude(Parser).LastUsed), IMG_INFO);
124+
TreeView.AddNode(n, 'InDefines: ' + TCodetoolsInclude(Parser).InDefines.ToString);
124125

125126
DebugClassTypes(Parser, TreeView, n);
126127
end;

Source/ide/codetools/simba.ide_codetools_includes.pas

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ TCodetoolsInclude = class(TCodeParser)
6363
property Plugins: TStringArray read GetPlugins;
6464
property RefCount: Integer read FRefCount;
6565
property LastUsed: Integer read FLastUsed;
66+
property InDefines: TSaveDefinesRec read FInDefines;
6667

6768
function IsOutdated: Boolean;
6869
function IncRef: TCodetoolsInclude;
@@ -122,7 +123,7 @@ function TCodetoolsInclude.GetPlugins: TStringArray;
122123
function TCodetoolsInclude.GetHash: String;
123124
begin
124125
if FHash.IsNull then
125-
FHash := inherited + FInDefines.Defines + IntToStr(FInDefines.Stack) + FPlugins.Text;
126+
FHash := inherited + FInDefines.ToString + FPlugins.Text;
126127

127128
Result := FHash;
128129
end;
@@ -306,7 +307,7 @@ function TCodetoolsIncludes.GetInclude(Defines: TSaveDefinesRec; IncludedFiles:
306307
if (FParsers[I].Lexer.FileName = FileName) then
307308
with TCodetoolsInclude(FParsers[I]) do
308309
begin
309-
if (FInDefines.Stack <> Defines.Stack) or (FInDefines.Defines <> Defines.Defines) then
310+
if not FInDefines.IsEqual(Defines) then
310311
begin
311312
{$IFDEF PARSER_CACHE_DEBUG}
312313
DebugLn('[Codetools]: Cache hit "%s" but not used (defines mismatch) %d, %d', [Lexer.FileName, FRefCount, FLastUsed + 1]);

Source/ide/codetools/simba.ide_codetools_parser.pas

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,8 +1552,7 @@ function TCodeParser.GetHash: String;
15521552
begin
15531553
if FHash.IsNull then
15541554
begin
1555-
with Lexer.SaveDefines() do
1556-
Builder.Append(Defines + IntToStr(Stack));
1555+
Builder.Append(Lexer.SaveDefines().ToString());
15571556
for I := 0 to fLexers.Count - 1 do
15581557
Builder.Append(fLexers[i].FileName + IntToStr(fLexers[i].FileAge));
15591558

0 commit comments

Comments
 (0)