chore: Use var everywhere (#2294)

This commit is contained in:
Kamron Batman 2025-12-27 16:47:28 -08:00 • committed by GitHub
parent 0b34cc4417
commit ebaf104935
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
267 changed files with 873 additions and 873 deletions

View file

@ -84,7 +84,7 @@ public ref struct RawInterpolatedStringHandler
[MethodImpl(MethodImplOptions.AggressiveInlining)] // used only on a few hot paths
public void Clear()
{
char[]? toReturn = _arrayToReturnToPool;
var toReturn = _arrayToReturnToPool;
this = default; // defensive clear
if (toReturn is not null)
{
@ -102,8 +102,8 @@ public ref struct RawInterpolatedStringHandler
{
if (value.Length == 1)
{
Span<char> chars = _chars;
int pos = _pos;
var chars = _chars;
var pos = _pos;
if ((uint)pos < (uint)chars.Length)
{
chars[pos] = value[0];
@ -312,7 +312,7 @@ public ref struct RawInterpolatedStringHandler
/// <param name="alignment">Minimum number of characters that should be written for this value. If the value is negative, it indicates left-aligned and the required minimum is the absolute value.</param>
public void AppendFormatted<T>(T value, int alignment)
{
int startingPos = _pos;
var startingPos = _pos;
AppendFormatted(value);
if (alignment != 0)
{
@ -326,7 +326,7 @@ public ref struct RawInterpolatedStringHandler
/// <param name="alignment">Minimum number of characters that should be written for this value. If the value is negative, it indicates left-aligned and the required minimum is the absolute value.</param>
public void AppendFormatted<T>(T value, int alignment, string? format)
{
int startingPos = _pos;
var startingPos = _pos;
AppendFormatted(value, format);
if (alignment != 0)
{
@ -357,14 +357,14 @@ public ref struct RawInterpolatedStringHandler
/// <param name="format">The format string.</param>
public void AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string? format = null)
{
bool leftAlign = false;
var leftAlign = false;
if (alignment < 0)
{
leftAlign = true;
alignment = -alignment;
}
int paddingRequired = alignment - value.Length;
var paddingRequired = alignment - value.Length;
if (paddingRequired <= 0)
{
// The value is as large or larger than the required amount of padding,
@ -477,7 +477,7 @@ public ref struct RawInterpolatedStringHandler
Debug.Assert(_hasCustomFormatter);
Debug.Assert(_provider != null);
ICustomFormatter? formatter = (ICustomFormatter?)_provider.GetFormat(typeof(ICustomFormatter));
var formatter = (ICustomFormatter?)_provider.GetFormat(typeof(ICustomFormatter));
Debug.Assert(formatter != null, "An incorrectly written provider said it implemented ICustomFormatter, and then didn't");
if (formatter?.Format(format, value, _provider) is string customFormatted)
@ -494,16 +494,16 @@ public ref struct RawInterpolatedStringHandler
Debug.Assert(startingPos >= 0 && startingPos <= _pos);
Debug.Assert(alignment != 0);
int charsWritten = _pos - startingPos;
var charsWritten = _pos - startingPos;
bool leftAlign = false;
var leftAlign = false;
if (alignment < 0)
{
leftAlign = true;
alignment = -alignment;
}
int paddingNeeded = alignment - charsWritten;
var paddingNeeded = alignment - charsWritten;
if (paddingNeeded > 0)
{
EnsureCapacityForAdditionalChars(paddingNeeded);
@ -583,13 +583,13 @@ public ref struct RawInterpolatedStringHandler
// ints that could technically overflow if someone tried to, for example, append a huge string to a huge string, we also clamp to int.MaxValue.
// Even if the array creation fails in such a case, we may later fail in ToStringAndClear.
uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)_chars.Length * 2, 0x3FFFFFDF));
int arraySize = (int)Math.Clamp(newCapacity, MinimumArrayPoolLength, int.MaxValue);
var newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)_chars.Length * 2, 0x3FFFFFDF));
var arraySize = (int)Math.Clamp(newCapacity, MinimumArrayPoolLength, int.MaxValue);
char[] newArray = STArrayPool<char>.Shared.Rent(arraySize);
var newArray = STArrayPool<char>.Shared.Rent(arraySize);
_chars[.._pos].CopyTo(newArray);
char[]? toReturn = _arrayToReturnToPool;
var toReturn = _arrayToReturnToPool;
_chars = _arrayToReturnToPool = newArray;
if (toReturn is not null)