Remove micro-optimization for old field values

このコミットが含まれているのは:
Sergio Pedri committed 2024-10-17 21:41:03 -07:00
1 親 57f1d3902b
コミット 9f789d1bb3
3ファイル変更
-38

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

@@ -58,37 +58,6 @@ partial class CanvasEffectPropertyGenerator
return CanvasEffectInvalidationType.Update;
}
/// <summary>
/// Checks whether the generated code has to directly reference the old property value.
/// </summary>
/// <param name="propertySymbol">The input <see cref="IPropertySymbol"/> instance to process.</param>
/// <returns>Whether the generated code needs direct access to the old property value.</returns>
public static bool IsOldPropertyValueDirectlyReferenced(IPropertySymbol propertySymbol)
{
// Check On<PROPERTY_NAME>Changing(<PROPERTY_TYPE> oldValue, <PROPERTY_TYPE> newValue) first
foreach (ISymbol symbol in propertySymbol.ContainingType.GetMembers($"On{propertySymbol.Name}Changing"))
{
// No need to be too specific as we're not expecting false positives (which also wouldn't really
// cause any problems anyway, just produce slightly worse codegen). Just checking the number of
// parameters is good enough, and keeps the code very simple and cheap to run.
if (symbol is IMethodSymbol { Parameters.Length: 2 })
{
return true;
}
}
// Do the same for On<PROPERTY_NAME>Changed(<PROPERTY_TYPE> oldValue, <PROPERTY_TYPE> newValue)
foreach (ISymbol symbol in propertySymbol.ContainingType.GetMembers($"On{propertySymbol.Name}Changed"))
{
if (symbol is IMethodSymbol { Parameters.Length: 2 })
{
return true;
}
}
return false;
}
public static void WritePropertyDeclarations(EquatableArray<CanvasEffectPropertyInfo> properties, IndentedTextWriter writer)
{
// First, generate all partial property implementations at the top of the partial type declaration
-5
ファイルの表示
@@ -45,10 +45,6 @@ public sealed partial class CanvasEffectPropertyGenerator : IIncrementalGenerato
token.ThrowIfCancellationRequested();
bool isOldPropertyValueDirectlyReferenced = Execute.IsOldPropertyValueDirectlyReferenced(propertySymbol);
token.ThrowIfCancellationRequested();
CanvasEffectInvalidationType invalidationType = Execute.GetCanvasEffectInvalidationType(context.Attributes[0]);
token.ThrowIfCancellationRequested();
@@ -67,7 +63,6 @@ public sealed partial class CanvasEffectPropertyGenerator : IIncrementalGenerato
Hierarchy: hierarchyInfo,
PropertyName: propertySymbol.Name,
TypeNameWithNullabilityAnnotations: typeNameWithNullabilityAnnotations,
IsOldPropertyValueDirectlyReferenced: isOldPropertyValueDirectlyReferenced,
IsReferenceTypeOrUnconstraindTypeParameter: isReferenceTypeOrUnconstraindTypeParameter,
InvalidationType: invalidationType);
})
-2
ファイルの表示
@@ -8,13 +8,11 @@ namespace ComputeSharp.D2D1.WinUI.SourceGenerators.Models;
/// <param name="Hierarchy">The hierarchy info for the shader type.</param>
/// <param name="TypeNameWithNullabilityAnnotations">The type name for the generated property, including nullability annotations.</param>
/// <param name="PropertyName">The generated property name.</param>
/// <param name="IsOldPropertyValueDirectlyReferenced">Whether the old property value is being directly referenced.</param>
/// <param name="IsReferenceTypeOrUnconstraindTypeParameter">Indicates whether the property is of a reference type or an unconstrained type parameter.</param>
/// <param name="InvalidationType">The invalidation type to request.</param>
internal sealed record CanvasEffectPropertyInfo(
HierarchyInfo Hierarchy,
string PropertyName,
string TypeNameWithNullabilityAnnotations,
bool IsOldPropertyValueDirectlyReferenced,
bool IsReferenceTypeOrUnconstraindTypeParameter,
CanvasEffectInvalidationType InvalidationType);