Skip to content

Commit f53ac6a

Browse files
committed
Merge pull request #1283 from autoboosh/resolverspeed
Small parser/resolver performance improvements
2 parents 9ba4755 + e81b57b commit f53ac6a

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

RetailCoder.VBE/Inspections/InspectionBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ public abstract class InspectionBase : IInspection
1010
{
1111
protected readonly RubberduckParserState State;
1212
private readonly CodeInspectionSeverity _defaultSeverity;
13+
private readonly string _name;
1314

1415
protected InspectionBase(RubberduckParserState state, CodeInspectionSeverity defaultSeverity = CodeInspectionSeverity.Warning)
1516
{
1617
State = state;
1718
_defaultSeverity = defaultSeverity;
1819
Severity = _defaultSeverity;
20+
_name = GetType().Name;
1921
}
2022

2123
/// <summary>
@@ -42,7 +44,7 @@ protected InspectionBase(RubberduckParserState state, CodeInspectionSeverity def
4244
/// <summary>
4345
/// The inspection type name, obtained by reflection.
4446
/// </summary>
45-
public string Name { get { return GetType().Name; } }
47+
public string Name { get { return _name; } }
4648

4749
/// <summary>
4850
/// Inspection severity level. Can control whether an inspection is enabled.

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private void ParserState_StateChanged(object sender, EventArgs e)
8080
{
8181
Debug.WriteLine("CodeExplorerViewModel handles StateChanged...");
8282
IsBusy = _state.Status == ParserState.Parsing;
83-
if (_state.Status != ParserState.Parsed)
83+
if (_state.Status != ParserState.Ready)
8484
{
8585
return;
8686
}

RetailCoder.VBE/UI/ToDoItems/ToDoExplorerViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public ICommand RefreshCommand
5151
private async void _state_StateChanged(object sender, EventArgs e)
5252
{
5353
Debug.WriteLine("ToDoExplorerViewModel handles StateChanged...");
54-
if (_state.Status != ParserState.Parsed)
54+
if (_state.Status != ParserState.Ready)
5555
{
5656
return;
5757
}

Rubberduck.Parsing/Symbols/IdentifierReference.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Antlr4.Runtime;
2-
using Microsoft.CSharp.RuntimeBinder;
32
using Rubberduck.Parsing.Grammar;
43
using Rubberduck.VBEditor;
4+
using System.Linq;
55

66
namespace Rubberduck.Parsing.Symbols
77
{
@@ -115,8 +115,7 @@ public bool HasTypeHint(out string token)
115115
_hasTypeHint = false;
116116
return false;
117117
}
118-
119-
var method = Context.Parent.GetType().GetMethod("typeHint");
118+
var method = Context.Parent.GetType().GetMethods().FirstOrDefault(m => m.Name == "typeHint");
120119
if (method == null)
121120
{
122121
token = null;

Rubberduck.VBEEditor/QualifiedModuleName.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public QualifiedModuleName(VBComponent component)
2424

2525
_component = component;
2626
_componentName = component == null ? string.Empty : component.Name;
27+
_project = component == null ? null : component.Collection.Parent;
2728
_projectName = component == null ? string.Empty : component.Collection.Parent.Name;
2829
_projectHashCode = component == null ? 0 : component.Collection.Parent.GetHashCode();
2930

@@ -47,7 +48,6 @@ public QualifiedModuleName(VBComponent component)
4748
public QualifiedModuleName(string projectName, string componentName)
4849
{
4950
_project = null; // field is only assigned when the instance refers to a VBProject.
50-
5151
_projectName = projectName;
5252
_componentName = componentName;
5353
_component = null;
@@ -64,7 +64,7 @@ public QualifiedMemberName QualifyMemberName(string member)
6464
public VBComponent Component { get { return _component; } }
6565

6666
private readonly VBProject _project;
67-
public VBProject Project { get { return _project ?? (_component == null ? null : _component.Collection.Parent); } }
67+
public VBProject Project { get { return _project; } }
6868

6969
private readonly int _projectHashCode;
7070
public int ProjectHashCode { get { return _projectHashCode; } }

0 commit comments

Comments
 (0)