Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJb Evain <jbevain@gmail.com>2015-06-01 16:42:35 +0300
committerJb Evain <jbevain@gmail.com>2015-06-01 16:42:35 +0300
commitb2aff21c220b3736beccdf03a708989712d33913 (patch)
treefa2a002dadeb5bea6b92246788aa427827d2eac5
parent83af39c4e3ba7a8c36f94d177654f7d97561239c (diff)
parentb7e21cd7db215b2d06274c58769a397e53aef3c9 (diff)
Merge pull request #221 from gluck/perfs
Performance improvements
-rw-r--r--Mono.Cecil.Metadata/MetadataToken.cs9
-rw-r--r--Mono.Cecil/Import.cs40
-rw-r--r--Mono.Collections.Generic/Collection.cs2
3 files changed, 47 insertions, 4 deletions
diff --git a/Mono.Cecil.Metadata/MetadataToken.cs b/Mono.Cecil.Metadata/MetadataToken.cs
index 8cc10ea..a8b712e 100644
--- a/Mono.Cecil.Metadata/MetadataToken.cs
+++ b/Mono.Cecil.Metadata/MetadataToken.cs
@@ -8,9 +8,11 @@
// Licensed under the MIT/X11 license.
//
+using System;
+
namespace Mono.Cecil {
- public struct MetadataToken {
+ public struct MetadataToken : IEquatable<MetadataToken> {
readonly uint token;
@@ -59,6 +61,11 @@ namespace Mono.Cecil {
return (int) token;
}
+ public bool Equals (MetadataToken other)
+ {
+ return other.token == token;
+ }
+
public override bool Equals (object obj)
{
if (obj is MetadataToken) {
diff --git a/Mono.Cecil/Import.cs b/Mono.Cecil/Import.cs
index 8a3345a..fa5a979 100644
--- a/Mono.Cecil/Import.cs
+++ b/Mono.Cecil/Import.cs
@@ -759,7 +759,7 @@ namespace Mono.Cecil {
for (int i = 0; i < references.Count; i++) {
var reference = references [i];
- if (name_reference.FullName != reference.FullName) // TODO compare field by field
+ if (!Equals (name_reference, reference))
continue;
assembly_reference = reference;
@@ -769,6 +769,44 @@ namespace Mono.Cecil {
assembly_reference = null;
return false;
}
+
+ private static bool Equals (byte [] a, byte [] b)
+ {
+ if (Object.ReferenceEquals (a, b))
+ return true;
+ if (a == null)
+ return false;
+ if (a.Length != b.Length)
+ return false;
+ for (int i = 0; i < a.Length; i++)
+ if (a [i] != b [i])
+ return false;
+ return true;
+ }
+
+ private static bool Equals<T> (T a, T b) where T : class, IEquatable<T>
+ {
+ if (Object.ReferenceEquals (a, b))
+ return true;
+ if (a == null)
+ return false;
+ return a.Equals (b);
+ }
+
+ private static bool Equals (AssemblyNameReference a, AssemblyNameReference b)
+ {
+ if (Object.ReferenceEquals (a, b))
+ return true;
+ if (a.Name != b.Name)
+ return false;
+ if (!Equals (a.Version, b.Version))
+ return false;
+ if (a.Culture != b.Culture)
+ return false;
+ if (!Equals (a.PublicKeyToken, b.PublicKeyToken))
+ return false;
+ return true;
+ }
}
#endif
diff --git a/Mono.Collections.Generic/Collection.cs b/Mono.Collections.Generic/Collection.cs
index 46f2abd..015d271 100644
--- a/Mono.Collections.Generic/Collection.cs
+++ b/Mono.Collections.Generic/Collection.cs
@@ -161,7 +161,6 @@ namespace Mono.Collections.Generic {
OnRemove (item, index);
Shift (index, -1);
- Array.Clear (items, size, 1);
version++;
}
@@ -174,7 +173,6 @@ namespace Mono.Collections.Generic {
OnRemove (item, index);
Shift (index, -1);
- Array.Clear (items, size, 1);
version++;
return true;