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