From 015bdd60621a032ec94e9d96305d1dd1e52eec0a Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Wed, 27 May 2020 15:27:38 +0200 Subject: [PATCH] symlist, minor perf improvment --- dexed-d/src/symlist.d | 41 +++++++++++++++++++++++++++-------------- src/u_symlist.pas | 27 ++++++++++++++------------- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/dexed-d/src/symlist.d b/dexed-d/src/symlist.d index 1f5a5f49..45965808 100644 --- a/dexed-d/src/symlist.d +++ b/dexed-d/src/symlist.d @@ -3,7 +3,7 @@ module symlist; import core.stdc.string; import - std.array, std.traits, std.conv, std.json, std.format, + std.array, std.conv, std.json, std.format, std.algorithm, std.string; import iz.memory: construct, destruct, MustAddGcRange, TellRangeAdded, NoGc; @@ -85,6 +85,7 @@ enum SymbolType string makeSymbolTypeArray() { + import std.traits : EnumMembers; string result = "string[SymbolType.max + 1] symbolTypeStrings = ["; foreach(st; EnumMembers!SymbolType) result ~= `"` ~ to!string(st) ~ `",`; @@ -306,11 +307,6 @@ static assert (!MustAddGcRange!(SymbolListBuilder!(ListFmt.Pas))); namedVisitorImpl!(AnonymousEnumMember, SymbolType._enum)(decl); } - override void visit(const AnonymousEnumDeclaration decl) - { - decl.accept(this); - } - override void visit(const AutoDeclarationPart decl) { otherVisitorImpl(decl, SymbolType._variable, decl.identifier.text, @@ -437,21 +433,38 @@ static assert (!MustAddGcRange!(SymbolListBuilder!(ListFmt.Pas))); otherVisitorImpl(decl, SymbolType._function, "shared static dtor", decl.line, decl.column); } + override void visit(const AliasInitializer) {} + override void visit(const AlignAttribute) {} + override void visit(const ArrayInitializer) {} + override void visit(const AsmStatement) {} + override void visit(const AtAttribute) {} + override void visit(const Attribute) {} + override void visit(const AttributeDeclaration) {} + override void visit(const BaseClassList) {} + override void visit(const BreakStatement) {} + override void visit(const Catches) {} + override void visit(const Constraint) {} + override void visit(const ContinueStatement) {} + override void visit(const Deprecated) {} override void visit(const Expression) {} override void visit(const ExpressionNode) {} override void visit(const ExpressionStatement) {} - override void visit(const PragmaStatement) {} - override void visit(const Initializer) {} + override void visit(const FunctionAttribute) {} override void visit(const FunctionContract) {} - override void visit(const AsmStatement) {} - override void visit(const ReturnStatement) {} - override void visit(const BreakStatement) {} - override void visit(const ContinueStatement) {} override void visit(const GotoStatement) {} + override void visit(const Initializer) {} + override void visit(const LabeledStatement) {} + override void visit(const MemberFunctionAttribute){} override void visit(const MixinDeclaration) {} + override void visit(const NamespaceList) {} + override void visit(const PragmaStatement) {} + override void visit(const ReturnStatement) {} + override void visit(const StaticAssertDeclaration){} + override void visit(const StaticAssertStatement){} + override void visit(const StructInitializer) {} + override void visit(const SynchronizedStatement){} + override void visit(const ThrowStatement) {} override void visit(const Type) {} override void visit(const Type2) {} - override void visit(const StaticAssertStatement){} - override void visit(const StaticAssertDeclaration){} } diff --git a/src/u_symlist.pas b/src/u_symlist.pas index 8e250550..1e297949 100644 --- a/src/u_symlist.pas +++ b/src/u_symlist.pas @@ -847,12 +847,12 @@ begin if fTreeDataFromThread.isEmpty or ndAlias.isNil then exit; + tree.BeginUpdate; clearTree; updateVisibleCat; fSyms.LoadFromString(fTreeDataFromThread); f := TreeFilterEdit1.Filter; TreeFilterEdit1.Text := ''; - tree.BeginUpdate; for i := 0 to fSyms.symbols.Count-1 do symbolToTreeNode(nil, fSyms.symbols[i]); if fAutoExpandErrors then @@ -871,9 +871,9 @@ begin end; if fSmartExpander then smartExpand; - tree.EndUpdate; if f.isNotEmpty then TreeFilterEdit1.Text := f; + tree.EndUpdate; minimizeGcHeap(); end; @@ -881,14 +881,14 @@ procedure TSymbolListWidget.smartExpand; var i: integer; n: TTreeNode; - target: NativeUint; - nearest: NativeUint = 0; + target: PtrUInt; + nearest: PtrUInt = 0; toExpand: TTreeNode = nil; procedure look(root: TTreeNode); var i: integer; - line: NativeUint; + j: PtrUInt; begin for i := 0 to root.Count-1 do begin @@ -897,19 +897,20 @@ var continue; if n.Parent.isNil then continue; - case n.Parent.Text of - 'Alias', 'Enum', 'Import', 'Variable': + if (n.Parent = ndAlias) + or (n.Parent = ndEnum) + or (n.Parent = ndImp) + or (n.Parent = ndVar) then continue; - end; {$PUSH}{$WARNINGS OFF}{$HINTS OFF} - line := NativeUInt(n.Data); + j := NativeUInt(n.Data); {$POP} - if line > target then + if j > target then continue; - if line > nearest then + if j > nearest then begin - nearest := line; - toExpand := n; + nearest := j; + toExpand := n; end; end; end;