[ 
https://issues.apache.org/jira/browse/AVRO-3327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17484438#comment-17484438
 ] 

ASF subversion and git services commented on AVRO-3327:
-------------------------------------------------------

Commit 332e403d0639490c9ed4b253532bdda137d232f1 in avro's branch 
refs/heads/branch-1.11 from Kyle Schoonover
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=332e403 ]

AVRO-3327 Implemented pattern matching on Equals check (#1478)

Co-authored-by: Kyle T. Schoonover <[email protected]>
(cherry picked from commit 2af5d7e0116d53ca706b6e5a5f3b45e7d317ef7d)


> 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: 20m
>  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)

Reply via email to