Kyle Schoonover created AVRO-3327:
-------------------------------------

             Summary: Use Pattern Matching to avoid is check followed by cast
                 Key: AVRO-3327
                 URL: https://issues.apache.org/jira/browse/AVRO-3327
             Project: Apache Avro
          Issue Type: Improvement
          Components: csharp
    Affects Versions: 1.11.1
            Reporter: Kyle Schoonover


{code:java}
return (obj is AvroDecimal) && Equals((AvroDecimal)obj); {code}
In the current code we are checking obj to see if it is in fact an AvroDecimal, 
then we cast it for the next check (technically creating a new variable in 
memory).  Since we have already validated it's value type there is no need to 
cast it.

Suggested Change:
{code:java}
return (obj is AvroDecimal @decimal) && Equals(@decimal); {code}
 

Pattern Matching Overview: [Pattern matching overview - C# guide | Microsoft 
Docs|https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/pattern-matching]



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to