You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/01/26 21:25:00 UTC

[jira] [Updated] (AVRO-3327) Use Pattern Matching to avoid is check followed by cast

     [ https://issues.apache.org/jira/browse/AVRO-3327?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

ASF GitHub Bot updated AVRO-3327:
---------------------------------
    Labels: pull-request-available  (was: )

> 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
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {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)