Add .this qualifier to all field accesses

このコミットが含まれているのは:
Sergio Pedri committed 2022-10-15 09:10:18 -07:00
1 親 f2ed8a2d3b
コミット b9a133b74c
75ファイル変更
+339 -335

検索条件に一致するファイルはありません

+32 -32
ファイルの表示
@@ -61,10 +61,10 @@ internal ref struct FormatInterpolatedStringHandler
{
this.format = format;
this.formatProvider = formatProvider;
characters = initialBuffer;
arrayToReturnToPool = null;
position = 0;
hasCustomFormatter = formatProvider is not null && HasCustomFormatter(formatProvider);
this.characters = initialBuffer;
this.arrayToReturnToPool = null;
this.position = 0;
this.hasCustomFormatter = formatProvider is not null && HasCustomFormatter(formatProvider);
}
/// <summary>
@@ -96,11 +96,11 @@ internal ref struct FormatInterpolatedStringHandler
public string ToStringAndClear()
{
#if NET6_0_OR_GREATER
string result = new(characters.Slice(0, position));
string result = new(this.characters.Slice(0, this.position));
#else
string result = characters.Slice(0, position).ToString();
string result = this.characters.Slice(0, this.position).ToString();
#endif
char[]? toReturn = arrayToReturnToPool;
char[]? toReturn = this.arrayToReturnToPool;
this = default;
@@ -121,14 +121,14 @@ internal ref struct FormatInterpolatedStringHandler
{
if (value.Length == 1)
{
Span<char> chars = characters;
int pos = position;
Span<char> chars = this.characters;
int pos = this.position;
if ((uint)pos < (uint)chars.Length)
{
chars[pos] = value[0];
position = pos + 1;
this.position = pos + 1;
}
else
{
@@ -140,8 +140,8 @@ internal ref struct FormatInterpolatedStringHandler
if (value.Length == 2)
{
Span<char> chars = characters;
int pos = position;
Span<char> chars = this.characters;
int pos = this.position;
if ((uint)pos < chars.Length - 1)
{
@@ -153,7 +153,7 @@ internal ref struct FormatInterpolatedStringHandler
Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(value.AsSpan()))));
#endif
position = pos + 2;
this.position = pos + 2;
}
else
{
@@ -173,12 +173,12 @@ internal ref struct FormatInterpolatedStringHandler
private void AppendStringDirect(string value)
{
#if NET6_0_OR_GREATER
if (value.TryCopyTo(characters.Slice(position)))
if (value.TryCopyTo(this.characters.Slice(this.position)))
#else
if (value.AsSpan().TryCopyTo(characters.Slice(position)))
if (value.AsSpan().TryCopyTo(this.characters.Slice(this.position)))
#endif
{
position += value.Length;
this.position += value.Length;
}
else
{
@@ -206,23 +206,23 @@ internal ref struct FormatInterpolatedStringHandler
where T : IFormattable
#endif
{
if (hasCustomFormatter)
if (this.hasCustomFormatter)
{
AppendCustomFormatter(value, format);
AppendCustomFormatter(value, this.format);
return;
}
#if NET6_0_OR_GREATER
int charsWritten;
while (!value.TryFormat(characters.Slice(position), out charsWritten, format, formatProvider))
while (!value.TryFormat(this.characters.Slice(this.position), out charsWritten, this.format, this.formatProvider))
{
Grow();
}
position += charsWritten;
this.position += charsWritten;
#else
AppendStringDirect(value.ToString(format, formatProvider));
AppendStringDirect(value.ToString(this.format, this.formatProvider));
#endif
}
@@ -245,9 +245,9 @@ internal ref struct FormatInterpolatedStringHandler
[MethodImpl(MethodImplOptions.NoInlining)]
private void AppendCustomFormatter<T>(T value, string? format)
{
ICustomFormatter? formatter = (ICustomFormatter?)formatProvider?.GetFormat(typeof(ICustomFormatter));
ICustomFormatter? formatter = (ICustomFormatter?)this.formatProvider?.GetFormat(typeof(ICustomFormatter));
if (formatter is not null && formatter.Format(format, value, formatProvider) is string customFormatted)
if (formatter is not null && formatter.Format(format, value, this.formatProvider) is string customFormatted)
{
AppendStringDirect(customFormatted);
}
@@ -263,12 +263,12 @@ internal ref struct FormatInterpolatedStringHandler
Grow(value.Length);
#if NET6_0_OR_GREATER
value.CopyTo(characters.Slice(position));
value.CopyTo(this.characters.Slice(this.position));
#else
value.AsSpan().CopyTo(characters.Slice(position));
value.AsSpan().CopyTo(this.characters.Slice(this.position));
#endif
position += value.Length;
this.position += value.Length;
}
/// <summary>
@@ -277,7 +277,7 @@ internal ref struct FormatInterpolatedStringHandler
[MethodImpl(MethodImplOptions.NoInlining)]
private void Grow(int additionalChars)
{
GrowCore((uint)position + (uint)additionalChars);
GrowCore((uint)this.position + (uint)additionalChars);
}
#if NET6_0_OR_GREATER
@@ -287,7 +287,7 @@ internal ref struct FormatInterpolatedStringHandler
[MethodImpl(MethodImplOptions.NoInlining)]
private void Grow()
{
GrowCore((uint)characters.Length + 1);
GrowCore((uint)this.characters.Length + 1);
}
#endif
@@ -297,7 +297,7 @@ internal ref struct FormatInterpolatedStringHandler
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void GrowCore(uint requiredMinCapacity)
{
uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)characters.Length * 2, 0x3FFFFFDF));
uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)this.characters.Length * 2, 0x3FFFFFDF));
#if NET6_0_OR_GREATER
int arraySize = (int)Math.Clamp(newCapacity, MinimumArrayPoolLength, int.MaxValue);
#else
@@ -305,11 +305,11 @@ internal ref struct FormatInterpolatedStringHandler
#endif
char[] newArray = ArrayPool<char>.Shared.Rent(arraySize);
characters.Slice(0, position).CopyTo(newArray);
this.characters.Slice(0, this.position).CopyTo(newArray);
char[]? toReturn = arrayToReturnToPool;
char[]? toReturn = this.arrayToReturnToPool;
characters = arrayToReturnToPool = newArray;
this.characters = this.arrayToReturnToPool = newArray;
if (toReturn is not null)
{
+22 -22
ファイルの表示
@@ -62,9 +62,9 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
this.format = format;
this.formatAsString = null;
this.formatProvider = formatProvider;
position = 0;
success = shouldAppend = destination.Length >= literalLength;
hasCustomFormatter = formatProvider is not null && FormatInterpolatedStringHandler.HasCustomFormatter(formatProvider);
this.position = 0;
this.success = shouldAppend = destination.Length >= literalLength;
this.hasCustomFormatter = formatProvider is not null && FormatInterpolatedStringHandler.HasCustomFormatter(formatProvider);
}
/// <summary>
@@ -106,13 +106,13 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
if (value.Length == 1)
{
Span<char> destination = this.destination;
int pos = position;
int pos = this.position;
if ((uint)pos < (uint)destination.Length)
{
destination[pos] = value[0];
position = pos + 1;
this.position = pos + 1;
return true;
}
@@ -123,7 +123,7 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
if (value.Length == 2)
{
Span<char> destination = this.destination;
int pos = position;
int pos = this.position;
if ((uint)pos < destination.Length - 1)
{
@@ -135,7 +135,7 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(value.AsSpan()))));
#endif
position = pos + 2;
this.position = pos + 2;
return true;
}
@@ -154,12 +154,12 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
private bool AppendStringDirect(string value)
{
#if NET6_0_OR_GREATER
if (value.TryCopyTo(destination.Slice(position)))
if (value.TryCopyTo(this.destination.Slice(this.position)))
#else
if (value.AsSpan().TryCopyTo(destination.Slice(position)))
if (value.AsSpan().TryCopyTo(this.destination.Slice(this.position)))
#endif
{
position += value.Length;
this.position += value.Length;
return true;
}
@@ -177,22 +177,22 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
where T : IFormattable
#endif
{
if (hasCustomFormatter)
if (this.hasCustomFormatter)
{
return AppendCustomFormatter(value, formatAsString ??= format.ToString());
return AppendCustomFormatter(value, this.formatAsString ??= this.format.ToString());
}
#if NET6_0_OR_GREATER
if (value.TryFormat(destination.Slice(position), out int charsWritten, format, formatProvider))
if (value.TryFormat(this.destination.Slice(this.position), out int charsWritten, this.format, this.formatProvider))
{
position += charsWritten;
this.position += charsWritten;
return true;
}
return Fail();
#else
return AppendStringDirect(value.ToString(formatAsString ??= format.ToString(), formatProvider));
return AppendStringDirect(value.ToString(this.formatAsString ??= this.format.ToString(), this.formatProvider));
#endif
}
@@ -202,7 +202,7 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
/// <param name="value">The value to write.</param>
public bool AppendFormatted(string? value)
{
if (hasCustomFormatter)
if (this.hasCustomFormatter)
{
return AppendCustomFormatter(value, format: null);
}
@@ -213,12 +213,12 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
}
#if NET6_0_OR_GREATER
if (value.TryCopyTo(destination.Slice(position)))
if (value.TryCopyTo(this.destination.Slice(this.position)))
#else
if (value.AsSpan().TryCopyTo(destination.Slice(position)))
if (value.AsSpan().TryCopyTo(this.destination.Slice(this.position)))
#endif
{
position += value.Length;
this.position += value.Length;
return true;
}
@@ -234,9 +234,9 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
[MethodImpl(MethodImplOptions.NoInlining)]
private bool AppendCustomFormatter<T>(T value, string? format)
{
ICustomFormatter? formatter = (ICustomFormatter?)formatProvider?.GetFormat(typeof(ICustomFormatter));
ICustomFormatter? formatter = (ICustomFormatter?)this.formatProvider?.GetFormat(typeof(ICustomFormatter));
if (formatter is not null && formatter.Format(format, value, formatProvider) is string customFormatted)
if (formatter is not null && formatter.Format(format, value, this.formatProvider) is string customFormatted)
{
return AppendStringDirect(customFormatted);
}
@@ -249,7 +249,7 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
/// </summary>
private bool Fail()
{
success = false;
this.success = false;
return false;
}
+2 -2
ファイルの表示
@@ -27,13 +27,13 @@ public readonly struct Bool
/// <inheritdoc/>
public override bool Equals(object? obj)
{
return obj is Bool x && value == x.value;
return obj is Bool x && this.value == x.value;
}
/// <inheritdoc/>
public override int GetHashCode()
{
return value.GetHashCode();
return this.value.GetHashCode();
}
/// <inheritdoc/>