Skip to content

Commit 3ac1925

Browse files
authored
Delete InlineArrays.cs and replace types (#121943)
Helps reduce the total number of types by replacing `ThreeObjects`, `TwoObjects`, and `EightObjects` with the existing `InlineArrayX<T>` types.
1 parent daced03 commit 3ac1925

File tree

7 files changed

+16
-66
lines changed

7 files changed

+16
-66
lines changed

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@
484484
<Compile Include="$(MSBuildThisFileDirectory)System\SearchValues\Strings\StringSearchValuesAhoCorasick.cs" />
485485
<Compile Include="$(MSBuildThisFileDirectory)System\SearchValues\Strings\StringSearchValuesRabinKarp.cs" />
486486
<Compile Include="$(MSBuildThisFileDirectory)System\IndexOutOfRangeException.cs" />
487-
<Compile Include="$(MSBuildThisFileDirectory)System\InlineArrays.cs" />
488487
<Compile Include="$(MSBuildThisFileDirectory)System\InsufficientExecutionStackException.cs" />
489488
<Compile Include="$(MSBuildThisFileDirectory)System\InsufficientMemoryException.cs" />
490489
<Compile Include="$(MSBuildThisFileDirectory)System\Int16.cs" />

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Diagnostics;
77
using System.Globalization;
88
using System.Numerics;
9+
using System.Runtime.CompilerServices;
910
using System.Runtime.InteropServices;
1011
using System.Threading;
1112

@@ -478,8 +479,8 @@ internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, IntPtr even
478479
int index;
479480
int refObjIndex = 0;
480481

481-
Debug.Assert(EtwAPIMaxRefObjCount == 8, $"{nameof(EtwAPIMaxRefObjCount)} must equal the number of fields in {nameof(EightObjects)}");
482-
EightObjects eightObjectStack = default;
482+
Debug.Assert(EtwAPIMaxRefObjCount == 8, $"{nameof(EtwAPIMaxRefObjCount)} must equal the number of fields in {nameof(InlineArray8<>)}");
483+
InlineArray8<object?> eightObjectStack = default;
483484
Span<int> refObjPosition = stackalloc int[EtwAPIMaxRefObjCount];
484485
Span<object?> dataRefObj = eightObjectStack;
485486

src/libraries/System.Private.CoreLib/src/System/IO/StreamWriter.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,7 @@ public override void Write([StringSyntax(StringSyntaxAttribute.CompositeFormat)]
531531
{
532532
if (GetType() == typeof(StreamWriter))
533533
{
534-
TwoObjects two = new TwoObjects(arg0, arg1);
535-
WriteFormatHelper(format, two, appendNewLine: false);
534+
WriteFormatHelper(format, [arg0, arg1], appendNewLine: false);
536535
}
537536
else
538537
{
@@ -544,8 +543,7 @@ public override void Write([StringSyntax(StringSyntaxAttribute.CompositeFormat)]
544543
{
545544
if (GetType() == typeof(StreamWriter))
546545
{
547-
ThreeObjects three = new ThreeObjects(arg0, arg1, arg2);
548-
WriteFormatHelper(format, three, appendNewLine: false);
546+
WriteFormatHelper(format, [arg0, arg1, arg2], appendNewLine: false);
549547
}
550548
else
551549
{
@@ -602,8 +600,7 @@ public override void WriteLine([StringSyntax(StringSyntaxAttribute.CompositeForm
602600
{
603601
if (GetType() == typeof(StreamWriter))
604602
{
605-
TwoObjects two = new TwoObjects(arg0, arg1);
606-
WriteFormatHelper(format, two, appendNewLine: true);
603+
WriteFormatHelper(format, [arg0, arg1], appendNewLine: true);
607604
}
608605
else
609606
{
@@ -615,8 +612,7 @@ public override void WriteLine([StringSyntax(StringSyntaxAttribute.CompositeForm
615612
{
616613
if (GetType() == typeof(StreamWriter))
617614
{
618-
ThreeObjects three = new ThreeObjects(arg0, arg1, arg2);
619-
WriteFormatHelper(format, three, appendNewLine: true);
615+
WriteFormatHelper(format, [arg0, arg1, arg2], appendNewLine: true);
620616
}
621617
else
622618
{

src/libraries/System.Private.CoreLib/src/System/InlineArrays.cs

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

src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/AsciiStringSearchValuesTeddyBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ internal abstract class AsciiStringSearchValuesTeddyBase<TBucketized, TStartCase
109109
// We may have up to 8 buckets.
110110
// If we have <= 8 strings, the buckets will be the strings themselves, and TBucketized.Value will be false.
111111
// If we have more than 8, the buckets will be string[], and TBucketized.Value will be true.
112-
private readonly EightObjects _buckets;
112+
private readonly InlineArray8<object?> _buckets;
113113

114114
private readonly Vector512<byte>
115115
_n0Low, _n0High,

src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,12 @@ public static string Format([StringSyntax(StringSyntaxAttribute.CompositeFormat)
459459

460460
public static string Format([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, object? arg0, object? arg1)
461461
{
462-
TwoObjects two = new TwoObjects(arg0, arg1);
463-
return FormatHelper(null, format, two);
462+
return FormatHelper(null, format, [arg0, arg1]);
464463
}
465464

466465
public static string Format([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, object? arg0, object? arg1, object? arg2)
467466
{
468-
ThreeObjects three = new ThreeObjects(arg0, arg1, arg2);
469-
return FormatHelper(null, format, three);
467+
return FormatHelper(null, format, [arg0, arg1, arg2]);
470468
}
471469

472470
public static string Format([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, params object?[] args)
@@ -499,14 +497,12 @@ public static string Format(IFormatProvider? provider, [StringSyntax(StringSynta
499497

500498
public static string Format(IFormatProvider? provider, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, object? arg0, object? arg1)
501499
{
502-
TwoObjects two = new TwoObjects(arg0, arg1);
503-
return FormatHelper(provider, format, two);
500+
return FormatHelper(provider, format, [arg0, arg1]);
504501
}
505502

506503
public static string Format(IFormatProvider? provider, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, object? arg0, object? arg1, object? arg2)
507504
{
508-
ThreeObjects three = new ThreeObjects(arg0, arg1, arg2);
509-
return FormatHelper(provider, format, three);
505+
return FormatHelper(provider, format, [arg0, arg1, arg2]);
510506
}
511507

512508
public static string Format(IFormatProvider? provider, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, params object?[] args)

src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,14 +1470,12 @@ public StringBuilder AppendFormat([StringSyntax(StringSyntaxAttribute.CompositeF
14701470

14711471
public StringBuilder AppendFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, object? arg0, object? arg1)
14721472
{
1473-
TwoObjects two = new TwoObjects(arg0, arg1);
1474-
return AppendFormat(null, format, (ReadOnlySpan<object?>)two);
1473+
return AppendFormat(null, format, [arg0, arg1]);
14751474
}
14761475

14771476
public StringBuilder AppendFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, object? arg0, object? arg1, object? arg2)
14781477
{
1479-
ThreeObjects three = new ThreeObjects(arg0, arg1, arg2);
1480-
return AppendFormat(null, format, (ReadOnlySpan<object?>)three);
1478+
return AppendFormat(null, format, [arg0, arg1, arg2]);
14811479
}
14821480

14831481
public StringBuilder AppendFormat([StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, params object?[] args)
@@ -1518,14 +1516,12 @@ public StringBuilder AppendFormat(IFormatProvider? provider, [StringSyntax(Strin
15181516

15191517
public StringBuilder AppendFormat(IFormatProvider? provider, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, object? arg0, object? arg1)
15201518
{
1521-
TwoObjects two = new TwoObjects(arg0, arg1);
1522-
return AppendFormat(provider, format, (ReadOnlySpan<object?>)two);
1519+
return AppendFormat(provider, format, [arg0, arg1]);
15231520
}
15241521

15251522
public StringBuilder AppendFormat(IFormatProvider? provider, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, object? arg0, object? arg1, object? arg2)
15261523
{
1527-
ThreeObjects three = new ThreeObjects(arg0, arg1, arg2);
1528-
return AppendFormat(provider, format, (ReadOnlySpan<object?>)three);
1524+
return AppendFormat(provider, format, [arg0, arg1, arg2]);
15291525
}
15301526

15311527
public StringBuilder AppendFormat(IFormatProvider? provider, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string format, params object?[] args)

0 commit comments

Comments
 (0)