Author: jbevain
Date: 2007-03-30 12:49:24 -0500 (Fri, 30 Mar 2007)
New Revision: 75221
Modified:
trunk/cecil/lib/ChangeLog
trunk/cecil/lib/CodeGen/templates/IndexedCollection.cs
trunk/cecil/lib/CodeGen/templates/NamedCollection.cs
trunk/cecil/lib/Mono.Cecil/ConstructorCollection.cs
trunk/cecil/lib/Mono.Cecil/EventDefinitionCollection.cs
trunk/cecil/lib/Mono.Cecil/ExternTypeCollection.cs
trunk/cecil/lib/Mono.Cecil/FieldDefinitionCollection.cs
trunk/cecil/lib/Mono.Cecil/MethodDefinitionCollection.cs
trunk/cecil/lib/Mono.Cecil/NestedTypeCollection.cs
trunk/cecil/lib/Mono.Cecil/PropertyDefinitionCollection.cs
trunk/cecil/lib/Mono.Cecil/TypeDefinitionCollection.cs
trunk/cecil/lib/Mono.Cecil/TypeReferenceCollection.cs
Log:
2007-03-30 Jb Evain <[EMAIL PROTECTED]>
* Collections:
Remove uneeded tests as an optimizations.
Based on a suggestion by Carlo Kok <[EMAIL PROTECTED]>.
Modified: trunk/cecil/lib/ChangeLog
===================================================================
--- trunk/cecil/lib/ChangeLog 2007-03-30 17:11:24 UTC (rev 75220)
+++ trunk/cecil/lib/ChangeLog 2007-03-30 17:49:24 UTC (rev 75221)
@@ -1,5 +1,9 @@
2007-03-30 Jb Evain <[EMAIL PROTECTED]>
+ * Collections:
+ Remove uneeded tests as an optimizations.
+ Based on a suggestion by Carlo Kok <[EMAIL PROTECTED]>.
+
* Mono.Cecil.Metadata/StringsHeap.cs:
Optimize GetStringAt, patch by:
Carlo Kok <[EMAIL PROTECTED]>
Modified: trunk/cecil/lib/CodeGen/templates/IndexedCollection.cs
===================================================================
--- trunk/cecil/lib/CodeGen/templates/IndexedCollection.cs 2007-03-30
17:11:24 UTC (rev 75220)
+++ trunk/cecil/lib/CodeGen/templates/IndexedCollection.cs 2007-03-30
17:49:24 UTC (rev 75221)
@@ -73,8 +73,7 @@
<%= member_visibility() %> void Add (<%=$cur_coll.type%> value)
{<%
if use_event?() %>
- if (!Contains (value))
- Attach (value);
+ Attach (value);
<% end %>
List.Add (value);
}
@@ -102,28 +101,24 @@
<%= member_visibility() %> void Insert (int index,
<%=$cur_coll.type%> value)
{<%
if use_event?() %>
- if (!this.Contains (value))
- Attach (value);
+ Attach (value);
<% end %>
List.Insert (index, value);
}
<%= member_visibility() %> void Remove (<%=$cur_coll.type%>
value)
- {<%
-if use_event?() %>
- if (this.Contains (value))
- Detach (value);
-<% end %>
+ {
List.Remove (value);
- }
+<% if use_event?() %>
+ Detach (value);
+<% end %> }
<%
if use_event?() %>
<%= member_visibility() %> new void RemoveAt (int index)
{
- Detach (this [index]);
-
- List.RemoveAt (index);
+ <%=$cur_coll.type%> item = this [index];
+ Remove (item);
}
<% end %>
protected override void OnValidate (object o)
Modified: trunk/cecil/lib/CodeGen/templates/NamedCollection.cs
===================================================================
--- trunk/cecil/lib/CodeGen/templates/NamedCollection.cs 2007-03-30
17:11:24 UTC (rev 75220)
+++ trunk/cecil/lib/CodeGen/templates/NamedCollection.cs 2007-03-30
17:49:24 UTC (rev 75221)
@@ -133,21 +133,19 @@
}
public void Remove (<%=$cur_coll.type%> value)
- {<%
- if use_event?() %>
- if (this.Contains (value))
- Detach (value);
-<% end %>
+ {
this.BaseRemove (value.FullName);
- }
+<% if use_event?() %>
+ Detach (value);
+<% end %> }
public void RemoveAt (int index)
- {<%
- if use_event?() %>
- Detach (this [index]);
-<% end %>
- this.BaseRemoveAt (index);
- }
+ {
+ <%=$cur_coll.type%> item = this [index];
+ Remove (item);
+<% if use_event?() %>
+ Detach (item);
+<% end %> }
public void CopyTo (Array ary, int index)
{
Modified: trunk/cecil/lib/Mono.Cecil/ConstructorCollection.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/ConstructorCollection.cs 2007-03-30 17:11:24 UTC
(rev 75220)
+++ trunk/cecil/lib/Mono.Cecil/ConstructorCollection.cs 2007-03-30 17:49:24 UTC
(rev 75221)
@@ -5,7 +5,7 @@
// Jb Evain ([EMAIL PROTECTED])
//
// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Sep 28 17:54:19 CEST 2006
+// Fri Mar 30 18:43:56 +0200 2007
//
// (C) 2005 Jb Evain
//
@@ -56,8 +56,7 @@
public void Add (MethodDefinition value)
{
- if (!Contains (value))
- Attach (value);
+ Attach (value);
List.Add (value);
}
@@ -83,26 +82,23 @@
public void Insert (int index, MethodDefinition value)
{
- if (!this.Contains (value))
- Attach (value);
+ Attach (value);
List.Insert (index, value);
}
public void Remove (MethodDefinition value)
{
- if (this.Contains (value))
- Detach (value);
-
List.Remove (value);
+
+ Detach (value);
}
public new void RemoveAt (int index)
{
- Detach (this [index]);
-
- List.RemoveAt (index);
+ MethodDefinition item = this [index];
+ Remove (item);
}
protected override void OnValidate (object o)
Modified: trunk/cecil/lib/Mono.Cecil/EventDefinitionCollection.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/EventDefinitionCollection.cs 2007-03-30
17:11:24 UTC (rev 75220)
+++ trunk/cecil/lib/Mono.Cecil/EventDefinitionCollection.cs 2007-03-30
17:49:24 UTC (rev 75221)
@@ -5,7 +5,7 @@
// Jb Evain ([EMAIL PROTECTED])
//
// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 01:22:48 CEST 2006
+// Fri Mar 30 18:43:57 +0200 2007
//
// (C) 2005 Jb Evain
//
@@ -56,12 +56,12 @@
public void Add (EventDefinition value)
{
- if (!Contains (value))
- Attach (value);
+ Attach (value);
List.Add (value);
}
+
public new void Clear ()
{
foreach (EventDefinition item in this)
@@ -82,25 +82,23 @@
public void Insert (int index, EventDefinition value)
{
- if (!this.Contains (value))
- Attach (value);
+ Attach (value);
List.Insert (index, value);
}
public void Remove (EventDefinition value)
{
- if (this.Contains (value))
- Detach (value);
-
List.Remove (value);
+
+ Detach (value);
}
+
public new void RemoveAt (int index)
{
- Detach (this [index]);
-
- List.RemoveAt (index);
+ EventDefinition item = this [index];
+ Remove (item);
}
protected override void OnValidate (object o)
Modified: trunk/cecil/lib/Mono.Cecil/ExternTypeCollection.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/ExternTypeCollection.cs 2007-03-30 17:11:24 UTC
(rev 75220)
+++ trunk/cecil/lib/Mono.Cecil/ExternTypeCollection.cs 2007-03-30 17:49:24 UTC
(rev 75221)
@@ -5,7 +5,7 @@
// Jb Evain ([EMAIL PROTECTED])
//
// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 03 00:35:29 CEST 2006
+// Fri Mar 30 18:43:57 +0200 2007
//
// (C) 2005 Jb Evain
//
@@ -124,17 +124,17 @@
public void Remove (TypeReference value)
{
- if (this.Contains (value))
- Detach (value);
+ this.BaseRemove (value.FullName);
- this.BaseRemove (value.FullName);
+ Detach (value);
}
public void RemoveAt (int index)
{
- Detach (this [index]);
+ TypeReference item = this [index];
+ Remove (item);
- this.BaseRemoveAt (index);
+ Detach (item);
}
public void CopyTo (Array ary, int index)
Modified: trunk/cecil/lib/Mono.Cecil/FieldDefinitionCollection.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/FieldDefinitionCollection.cs 2007-03-30
17:11:24 UTC (rev 75220)
+++ trunk/cecil/lib/Mono.Cecil/FieldDefinitionCollection.cs 2007-03-30
17:49:24 UTC (rev 75221)
@@ -5,7 +5,7 @@
// Jb Evain ([EMAIL PROTECTED])
//
// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 01:22:48 CEST 2006
+// Fri Mar 30 18:43:57 +0200 2007
//
// (C) 2005 Jb Evain
//
@@ -56,12 +56,12 @@
public void Add (FieldDefinition value)
{
- if (!Contains (value))
- Attach (value);
+ Attach (value);
List.Add (value);
}
+
public new void Clear ()
{
foreach (FieldDefinition item in this)
@@ -82,25 +82,23 @@
public void Insert (int index, FieldDefinition value)
{
- if (!this.Contains (value))
- Attach (value);
+ Attach (value);
List.Insert (index, value);
}
public void Remove (FieldDefinition value)
{
- if (this.Contains (value))
- Detach (value);
-
List.Remove (value);
+
+ Detach (value);
}
+
public new void RemoveAt (int index)
{
- Detach (this [index]);
-
- List.RemoveAt (index);
+ FieldDefinition item = this [index];
+ Remove (item);
}
protected override void OnValidate (object o)
Modified: trunk/cecil/lib/Mono.Cecil/MethodDefinitionCollection.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/MethodDefinitionCollection.cs 2007-03-30
17:11:24 UTC (rev 75220)
+++ trunk/cecil/lib/Mono.Cecil/MethodDefinitionCollection.cs 2007-03-30
17:49:24 UTC (rev 75221)
@@ -5,7 +5,7 @@
// Jb Evain ([EMAIL PROTECTED])
//
// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Sep 28 17:54:19 CEST 2006
+// Fri Mar 30 18:43:56 +0200 2007
//
// (C) 2005 Jb Evain
//
@@ -56,8 +56,7 @@
public void Add (MethodDefinition value)
{
- if (!Contains (value))
- Attach (value);
+ Attach (value);
List.Add (value);
}
@@ -83,26 +82,23 @@
public void Insert (int index, MethodDefinition value)
{
- if (!this.Contains (value))
- Attach (value);
+ Attach (value);
List.Insert (index, value);
}
public void Remove (MethodDefinition value)
{
- if (this.Contains (value))
- Detach (value);
-
List.Remove (value);
+
+ Detach (value);
}
public new void RemoveAt (int index)
{
- Detach (this [index]);
-
- List.RemoveAt (index);
+ MethodDefinition item = this [index];
+ Remove (item);
}
protected override void OnValidate (object o)
Modified: trunk/cecil/lib/Mono.Cecil/NestedTypeCollection.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/NestedTypeCollection.cs 2007-03-30 17:11:24 UTC
(rev 75220)
+++ trunk/cecil/lib/Mono.Cecil/NestedTypeCollection.cs 2007-03-30 17:49:24 UTC
(rev 75221)
@@ -5,7 +5,7 @@
// Jb Evain ([EMAIL PROTECTED])
//
// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 01:22:48 CEST 2006
+// Fri Mar 30 18:43:57 +0200 2007
//
// (C) 2005 Jb Evain
//
@@ -56,12 +56,12 @@
public void Add (TypeDefinition value)
{
- if (!Contains (value))
- Attach (value);
+ Attach (value);
List.Add (value);
}
+
public new void Clear ()
{
foreach (TypeDefinition item in this)
@@ -82,25 +82,23 @@
public void Insert (int index, TypeDefinition value)
{
- if (!this.Contains (value))
- Attach (value);
+ Attach (value);
List.Insert (index, value);
}
public void Remove (TypeDefinition value)
{
- if (this.Contains (value))
- Detach (value);
-
List.Remove (value);
+
+ Detach (value);
}
+
public new void RemoveAt (int index)
{
- Detach (this [index]);
-
- List.RemoveAt (index);
+ TypeDefinition item = this [index];
+ Remove (item);
}
protected override void OnValidate (object o)
Modified: trunk/cecil/lib/Mono.Cecil/PropertyDefinitionCollection.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/PropertyDefinitionCollection.cs 2007-03-30
17:11:24 UTC (rev 75220)
+++ trunk/cecil/lib/Mono.Cecil/PropertyDefinitionCollection.cs 2007-03-30
17:49:24 UTC (rev 75221)
@@ -5,7 +5,7 @@
// Jb Evain ([EMAIL PROTECTED])
//
// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 01:22:48 CEST 2006
+// Fri Mar 30 18:43:57 +0200 2007
//
// (C) 2005 Jb Evain
//
@@ -56,12 +56,12 @@
public void Add (PropertyDefinition value)
{
- if (!Contains (value))
- Attach (value);
+ Attach (value);
List.Add (value);
}
+
public new void Clear ()
{
foreach (PropertyDefinition item in this)
@@ -82,25 +82,23 @@
public void Insert (int index, PropertyDefinition value)
{
- if (!this.Contains (value))
- Attach (value);
+ Attach (value);
List.Insert (index, value);
}
public void Remove (PropertyDefinition value)
{
- if (this.Contains (value))
- Detach (value);
-
List.Remove (value);
+
+ Detach (value);
}
+
public new void RemoveAt (int index)
{
- Detach (this [index]);
-
- List.RemoveAt (index);
+ PropertyDefinition item = this [index];
+ Remove (item);
}
protected override void OnValidate (object o)
Modified: trunk/cecil/lib/Mono.Cecil/TypeDefinitionCollection.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/TypeDefinitionCollection.cs 2007-03-30
17:11:24 UTC (rev 75220)
+++ trunk/cecil/lib/Mono.Cecil/TypeDefinitionCollection.cs 2007-03-30
17:49:24 UTC (rev 75221)
@@ -5,7 +5,7 @@
// Jb Evain ([EMAIL PROTECTED])
//
// Generated by /CodeGen/cecil-gen.rb do not edit
-// Mon Nov 27 21:14:02 CET 2006
+// Fri Mar 30 18:43:56 +0200 2007
//
// (C) 2005 Jb Evain
//
@@ -124,17 +124,17 @@
public void Remove (TypeDefinition value)
{
- if (this.Contains (value))
- Detach (value);
+ this.BaseRemove (value.FullName);
- this.BaseRemove (value.FullName);
+ Detach (value);
}
public void RemoveAt (int index)
{
- Detach (this [index]);
+ TypeDefinition item = this [index];
+ Remove (item);
- this.BaseRemoveAt (index);
+ Detach (item);
}
public void CopyTo (Array ary, int index)
Modified: trunk/cecil/lib/Mono.Cecil/TypeReferenceCollection.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/TypeReferenceCollection.cs 2007-03-30
17:11:24 UTC (rev 75220)
+++ trunk/cecil/lib/Mono.Cecil/TypeReferenceCollection.cs 2007-03-30
17:49:24 UTC (rev 75221)
@@ -5,7 +5,7 @@
// Jb Evain ([EMAIL PROTECTED])
//
// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 03 00:35:28 CEST 2006
+// Fri Mar 30 18:43:56 +0200 2007
//
// (C) 2005 Jb Evain
//
@@ -124,17 +124,17 @@
public void Remove (TypeReference value)
{
- if (this.Contains (value))
- Detach (value);
+ this.BaseRemove (value.FullName);
- this.BaseRemove (value.FullName);
+ Detach (value);
}
public void RemoveAt (int index)
{
- Detach (this [index]);
+ TypeReference item = this [index];
+ Remove (item);
- this.BaseRemoveAt (index);
+ Detach (item);
}
public void CopyTo (Array ary, int index)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches