Browse Source

Applied some of the optimizations suggested by Kris Vandermotten. #150

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
9a35ee4404
  1. 4
      ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs
  2. 2
      ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs
  3. 4
      ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs
  4. 4
      ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs

4
ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp
public int PointerRank {
get {
return GetChildrenByRole(PointerRole).Count();
return GetChildrenByRole(PointerRole).Count;
}
set {
if (value < 0)
@ -141,7 +141,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -141,7 +141,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
public int Dimensions {
get { return 1 + GetChildrenByRole(Roles.Comma).Count(); }
get { return 1 + GetChildrenByRole(Roles.Comma).Count; }
set {
int d = this.Dimensions;
while (d > value) {

2
ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs

@ -96,7 +96,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -96,7 +96,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
if (name == null)
throw new ArgumentNullException("name");
IsVerbatim = name.StartsWith ("@");
IsVerbatim = name.Length > 0 && name[0] == '@';
this.Name = IsVerbatim ? name.Substring (1) : name;
this.startLocation = location;
}

4
ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs

@ -263,7 +263,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -263,7 +263,7 @@ namespace ICSharpCode.NRefactory.CSharp
#region Fields
public override IEntity VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
{
bool isSingleField = fieldDeclaration.Variables.Count() == 1;
bool isSingleField = fieldDeclaration.Variables.Count == 1;
Modifiers modifiers = fieldDeclaration.Modifiers;
DefaultField field = null;
foreach (VariableInitializer vi in fieldDeclaration.Variables) {
@ -476,7 +476,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -476,7 +476,7 @@ namespace ICSharpCode.NRefactory.CSharp
#region Events
public override IEntity VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
{
bool isSingleEvent = eventDeclaration.Variables.Count() == 1;
bool isSingleEvent = eventDeclaration.Variables.Count == 1;
Modifiers modifiers = eventDeclaration.Modifiers;
DefaultEvent ev = null;
foreach (VariableInitializer vi in eventDeclaration.Variables) {

4
ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs

@ -241,7 +241,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -241,7 +241,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
ResolveResult VisitFieldOrEventDeclaration(AttributedNode fieldOrEventDeclaration)
{
int initializerCount = fieldOrEventDeclaration.GetChildrenByRole(FieldDeclaration.Roles.Variable).Count();
int initializerCount = fieldOrEventDeclaration.GetChildrenByRole(FieldDeclaration.Roles.Variable).Count;
ResolveResult result = null;
for (AstNode node = fieldOrEventDeclaration.FirstChild; node != null; node = node.NextSibling) {
if (node.Role == FieldDeclaration.Roles.Variable) {
@ -939,7 +939,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -939,7 +939,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
firstInitializer != null ? firstInitializer.Initializer : null,
false);
int initializerCount = variableDeclarationStatement.Variables.Count();
int initializerCount = variableDeclarationStatement.Variables.Count;
ResolveResult result = null;
for (AstNode node = variableDeclarationStatement.FirstChild; node != null; node = node.NextSibling) {
if (node.Role == FieldDeclaration.Roles.Variable) {

Loading…
Cancel
Save