You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by fo...@apache.org on 2020/03/29 10:36:16 UTC

[avro] branch master updated: AVRO-2694: Simplify Comparison Check in Resolver (#774)

This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new 4062236  AVRO-2694: Simplify Comparison Check in Resolver (#774)
4062236 is described below

commit 40622368863c19f9b103927b85af9dd65d18aedb
Author: belugabehr <12...@users.noreply.github.com>
AuthorDate: Sun Mar 29 06:36:06 2020 -0400

    AVRO-2694: Simplify Comparison Check in Resolver (#774)
    
    * AVRO-2694: Simplify Comparison Check in Resolver
    
    * Revert minor refactor to lessen patch size
    
    Co-authored-by: David Mollitor <dm...@apache.org>
---
 .../src/main/java/org/apache/avro/Resolver.java    | 23 ++++++----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/lang/java/avro/src/main/java/org/apache/avro/Resolver.java b/lang/java/avro/src/main/java/org/apache/avro/Resolver.java
index b6a15ca..182a91b 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/Resolver.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/Resolver.java
@@ -763,16 +763,7 @@ public class Resolver {
     case ENUM: {
       final List<String> ws = write.getEnumSymbols();
       final List<String> rs = read.getEnumSymbols();
-      if (ws.size() != rs.size()) {
-        return false;
-      }
-      int i = 0;
-      for (; i < ws.size(); i++) {
-        if (!ws.get(i).equals(rs.get(i))) {
-          break;
-        }
-      }
-      return i == ws.size();
+      return ws.equals(rs);
     }
 
     case UNION: {
@@ -781,13 +772,12 @@ public class Resolver {
       if (wb.size() != rb.size()) {
         return false;
       }
-      int i = 0;
-      for (; i < wb.size(); i++) {
+      for (int i = 0; i < wb.size(); i++) {
         if (!unionEquiv(wb.get(i), rb.get(i), seen)) {
-          break;
+          return false;
         }
       }
-      return i == wb.size();
+      return true;
     }
 
     case RECORD: {
@@ -799,15 +789,14 @@ public class Resolver {
         if (wb.size() != rb.size()) {
           seen.put(wsc, false);
         } else {
-          int i = 0;
-          for (; i < wb.size(); i++) {
+          for (int i = 0; i < wb.size(); i++) {
             // Loop through each of the elements, and check if they are equal
             if (!wb.get(i).name().equals(rb.get(i).name())
                 || !unionEquiv(wb.get(i).schema(), rb.get(i).schema(), seen)) {
+              seen.put(wsc, false);
               break;
             }
           }
-          seen.put(wsc, (i == wb.size()));
         }
       }
       return seen.get(wsc);