Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/libraries/System.Private.CoreLib/src/System/ValueTuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ int IStructuralComparable.CompareTo(object? other, IComparer comparer)
public override int GetHashCode()
{
// We want to have a limited hash in this case. We'll use the first 7 elements of the tuple
if (Rest is not IValueTupleInternal)
if (Rest is not IValueTupleInternal rest)
{
return HashCode.Combine(Item1?.GetHashCode() ?? 0,
Item2?.GetHashCode() ?? 0,
Expand All @@ -2020,7 +2020,7 @@ public override int GetHashCode()
Item7?.GetHashCode() ?? 0);
}

int size = ((IValueTupleInternal)Rest).Length;
int size = rest.Length;
int restHashCode = Rest.GetHashCode();
if (size >= 8)
{
Expand Down Expand Up @@ -2170,19 +2170,19 @@ int IValueTupleInternal.GetHashCode(IEqualityComparer comparer)
/// </remarks>
public override string ToString()
{
if (Rest is IValueTupleInternal)
if (Rest is IValueTupleInternal rest)
{
return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ", " + ((IValueTupleInternal)Rest).ToStringEnd();
return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ", " + rest.ToStringEnd();
}

return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ", " + Rest.ToString() + ")";
}

string IValueTupleInternal.ToStringEnd()
{
if (Rest is IValueTupleInternal)
if (Rest is IValueTupleInternal rest)
{
return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ", " + ((IValueTupleInternal)Rest).ToStringEnd();
return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ", " + rest.ToStringEnd();
}

return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ", " + Rest.ToString() + ")";
Expand All @@ -2191,7 +2191,7 @@ string IValueTupleInternal.ToStringEnd()
/// <summary>
/// The number of positions in this data structure.
/// </summary>
int ITuple.Length => Rest is IValueTupleInternal ? 7 + ((IValueTupleInternal)Rest).Length : 8;
int ITuple.Length => Rest is IValueTupleInternal rest ? 7 + rest.Length : 8;

/// <summary>
/// Get the element at position <param name="index"/>.
Expand All @@ -2218,9 +2218,9 @@ string IValueTupleInternal.ToStringEnd()
return Item7;
}

if (Rest is IValueTupleInternal)
if (Rest is IValueTupleInternal rest)
{
return ((IValueTupleInternal)Rest)[index - 7];
return rest[index - 7];
}


Expand Down
Loading