Skip to content

Commit b584719

Browse files
Cleanup unused code from nativeaot and ilc (#116480)
* Use BitConverter * SequenceEqual(array) bounds to span * Use CollectionsMarshal.AsSpan * EqualOnlyComparerHelper * Count -> !Any * Unnecessary AsEnumerable * Remove unnecessary ToList call * Delete unnecessary Select(.ToString) * Cleanup FlagsToString --------- Co-authored-by: Austin Wise <[email protected]>
1 parent a87cf1b commit b584719

File tree

7 files changed

+63
-334
lines changed

7 files changed

+63
-334
lines changed

src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
44
</PropertyGroup>
@@ -168,7 +168,6 @@
168168
<Compile Include="System\Collections\Generic\ArraySortHelper.NativeAot.cs" />
169169
<Compile Include="System\Collections\Generic\Comparer.NativeAot.cs" />
170170
<Compile Include="System\Collections\Generic\EqualityComparer.NativeAot.cs" />
171-
<Compile Include="System\Collections\Generic\EqualOnlyComparer.cs" />
172171
<Compile Include="System\InvokeUtils.cs" />
173172
<Compile Include="System\IO\FileLoadException.NativeAot.cs" />
174173
<Compile Include="System\IO\Stream.NativeAot.cs" />

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Collections/Generic/EqualOnlyComparer.cs

Lines changed: 0 additions & 140 deletions
This file was deleted.

src/coreclr/tools/Common/Internal/LowLevelLinq/LowLevelEnumerable.ToList.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/coreclr/tools/Common/Internal/LowLevelLinq/LowLevelEnumerable.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,5 @@ public static IEnumerable<T> Where<T>(this IEnumerable<T> source, Func<T, bool>
3737
yield return value;
3838
}
3939
}
40-
41-
public static IEnumerable<T> AsEnumerable<T>(this IEnumerable<T> source)
42-
{
43-
Debug.Assert(source != null);
44-
return source;
45-
}
46-
47-
public static int Count<T>(this IEnumerable<T> enumeration)
48-
{
49-
Debug.Assert(enumeration != null);
50-
51-
var collection = enumeration as ICollection<T>;
52-
if (collection != null)
53-
return collection.Count;
54-
55-
int i = 0;
56-
foreach (T element in enumeration)
57-
{
58-
i++;
59-
}
60-
61-
return i;
62-
}
6340
}
6441
}

src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler.MetadataTransform.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Library</OutputType>
44
<AssemblyName>ILCompiler.MetadataTransform</AssemblyName>
@@ -27,7 +27,6 @@
2727
</ItemGroup>
2828
<ItemGroup>
2929
<Compile Include="$(CommonSourcePath)Internal\LowLevelLinq\LowLevelEnumerable.cs" />
30-
<Compile Include="$(CommonSourcePath)Internal\LowLevelLinq\LowLevelEnumerable.ToList.cs" />
3130
</ItemGroup>
3231
<ItemGroup>
3332
<Compile Include="$(NativeFormatCommonPath)\NativeFormat.cs" />

src/coreclr/tools/aot/ILCompiler.MetadataTransform/Internal/Metadata/NativeFormat/Writer/ConstantValues.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public partial class ConstantBooleanArray
1818
{
1919
public override string ToString()
2020
{
21-
//return "ConstantBooleanArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
22-
return "(Boolean[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
21+
//return "ConstantBooleanArray : {" + String.Join(", ", this.Value) + "}";
22+
return "(Boolean[]) {" + string.Join(", ", this.Value) + "}";
2323
}
2424
}
2525
public partial class ConstantCharValue
@@ -36,8 +36,8 @@ public partial class ConstantCharArray
3636
{
3737
public override string ToString()
3838
{
39-
//return "ConstantCharArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
40-
return "(Char[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
39+
//return "ConstantCharArray : {" + String.Join(", ", this.Value) + "}";
40+
return "(Char[]) {" + string.Join(", ", this.Value) + "}";
4141
}
4242
}
4343
public partial class ConstantStringValue
@@ -54,8 +54,8 @@ public partial class ConstantStringArray
5454
{
5555
public override string ToString()
5656
{
57-
//return "ConstantStringArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
58-
return "(String[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
57+
//return "ConstantStringArray : {" + String.Join(", ", this.Value) + "}";
58+
return "(String[]) {" + string.Join(", ", this.Value) + "}";
5959
}
6060
}
6161
public partial class ConstantByteValue
@@ -71,8 +71,8 @@ public partial class ConstantByteArray
7171
{
7272
public override string ToString()
7373
{
74-
//return "ConstantByteArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
75-
return "(Byte[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
74+
//return "ConstantByteArray : {" + String.Join(", ", this.Value) + "}";
75+
return "(Byte[]) {" + string.Join(", ", this.Value) + "}";
7676
}
7777
}
7878
public partial class ConstantSByteValue
@@ -88,8 +88,8 @@ public partial class ConstantSByteArray
8888
{
8989
public override string ToString()
9090
{
91-
//return "ConstantSByteArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
92-
return "(SByte[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
91+
//return "ConstantSByteArray : {" + String.Join(", ", this.Value) + "}";
92+
return "(SByte[]) {" + string.Join(", ", this.Value) + "}";
9393
}
9494
}
9595
public partial class ConstantInt16Value
@@ -105,8 +105,8 @@ public partial class ConstantInt16Array
105105
{
106106
public override string ToString()
107107
{
108-
//return "ConstantInt16Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
109-
return "(Int16[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
108+
//return "ConstantInt16Array : {" + String.Join(", ", this.Value) + "}";
109+
return "(Int16[]) {" + string.Join(", ", this.Value) + "}";
110110
}
111111
}
112112
public partial class ConstantUInt16Value
@@ -122,8 +122,8 @@ public partial class ConstantUInt16Array
122122
{
123123
public override string ToString()
124124
{
125-
//return "ConstantUInt16Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
126-
return "(UInt16[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
125+
//return "ConstantUInt16Array : {" + String.Join(", ", this.Value) + "}";
126+
return "(UInt16[]) {" + string.Join(", ", this.Value) + "}";
127127
}
128128
}
129129
public partial class ConstantInt32Value
@@ -139,8 +139,8 @@ public partial class ConstantInt32Array
139139
{
140140
public override string ToString()
141141
{
142-
//return "ConstantInt32Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
143-
return "(Int32[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
142+
//return "ConstantInt32Array : {" + String.Join(", ", this.Value) + "}";
143+
return "(Int32[]) {" + string.Join(", ", this.Value) + "}";
144144
}
145145
}
146146
public partial class ConstantUInt32Value
@@ -156,8 +156,8 @@ public partial class ConstantUInt32Array
156156
{
157157
public override string ToString()
158158
{
159-
//return "ConstantUInt32Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
160-
return "(UInt32[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
159+
//return "ConstantUInt32Array : {" + String.Join(", ", this.Value) + "}";
160+
return "(UInt32[]) {" + string.Join(", ", this.Value) + "}";
161161
}
162162
}
163163
public partial class ConstantInt64Value
@@ -173,8 +173,8 @@ public partial class ConstantInt64Array
173173
{
174174
public override string ToString()
175175
{
176-
//return "ConstantInt64Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
177-
return "(Int64[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
176+
//return "ConstantInt64Array : {" + String.Join(", ", this.Value) + "}";
177+
return "(Int64[]) {" + string.Join(", ", this.Value) + "}";
178178
}
179179
}
180180
public partial class ConstantUInt64Value
@@ -190,8 +190,8 @@ public partial class ConstantUInt64Array
190190
{
191191
public override string ToString()
192192
{
193-
//return "ConstantUInt64Array : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
194-
return "(UInt64[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
193+
//return "ConstantUInt64Array : {" + String.Join(", ", this.Value) + "}";
194+
return "(UInt64[]) {" + string.Join(", ", this.Value) + "}";
195195
}
196196
}
197197
public partial class ConstantSingleValue
@@ -207,8 +207,8 @@ public partial class ConstantSingleArray
207207
{
208208
public override string ToString()
209209
{
210-
//return "ConstantSingleArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
211-
return "(Single[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
210+
//return "ConstantSingleArray : {" + String.Join(", ", this.Value) + "}";
211+
return "(Single[]) {" + string.Join(", ", this.Value) + "}";
212212
}
213213
}
214214
public partial class ConstantDoubleValue
@@ -224,8 +224,8 @@ public partial class ConstantDoubleArray
224224
{
225225
public override string ToString()
226226
{
227-
//return "ConstantDoubleArray : {" + String.Join(", ", this.Value.Select(v => v.ToString())) + "}";
228-
return "(Double[]) {" + string.Join(", ", this.Value.Select(v => v.ToString())) + "}";
227+
//return "ConstantDoubleArray : {" + String.Join(", ", this.Value) + "}";
228+
return "(Double[]) {" + string.Join(", ", this.Value) + "}";
229229
}
230230
}
231231
public partial class ConstantReferenceValue

0 commit comments

Comments
 (0)