Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance optimization in DFA.IsEmpty and DFA.IsContextSensitive. #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions runtime/CSharp/Antlr4.Runtime/Dfa/DFA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public virtual bool IsEmpty
{
if (IsPrecedenceDfa)
{
return s0.Get().EdgeMap.Count == 0 && s0full.Get().EdgeMap.Count == 0;
return s0.Get().IsEdgeMapEmpty && s0full.Get().IsEdgeMapEmpty;
}
return s0.Get() == null && s0full.Get() == null;
}
Expand All @@ -260,7 +260,7 @@ public virtual bool IsContextSensitive
{
if (IsPrecedenceDfa)
{
return s0full.Get().EdgeMap.Count != 0;
return !s0full.Get().IsEdgeMapEmpty;
}
return s0full.Get() != null;
}
Expand Down
8 changes: 8 additions & 0 deletions runtime/CSharp/Antlr4.Runtime/Dfa/DFAState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ public virtual ReadOnlyDictionary<int, DFAState> EdgeMap
}
}

public bool IsEdgeMapEmpty
{
get
{
return edges.IsEmpty;
}
}

public virtual DFAState GetContextTarget(int invokingState)
{
lock (this)
Expand Down