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

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


The following commit(s) were added to refs/heads/master by this push:
     new 7792d57  [CALCITE-3891] Remove use of Pair.zip in RelTraitSet
7792d57 is described below

commit 7792d57036ac82958b9a3f53a38855c979f7b36a
Author: Chunwei Lei <[email protected]>
AuthorDate: Thu Apr 2 12:00:43 2020 +0800

    [CALCITE-3891] Remove use of Pair.zip in RelTraitSet
---
 .../java/org/apache/calcite/plan/RelTraitSet.java  | 24 ++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java 
b/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
index 8dc5391..70e45b7 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
@@ -17,7 +17,6 @@
 package org.apache.calcite.plan;
 
 import org.apache.calcite.runtime.FlatLists;
-import org.apache.calcite.util.Pair;
 
 import com.google.common.collect.ImmutableList;
 
@@ -320,8 +319,14 @@ public final class RelTraitSet extends 
AbstractList<RelTrait> {
    * @see org.apache.calcite.plan.RelTrait#satisfies(RelTrait)
    */
   public boolean satisfies(RelTraitSet that) {
-    for (Pair<RelTrait, RelTrait> pair : Pair.zip(traits, that.traits)) {
-      if (!pair.left.satisfies(pair.right)) {
+    final int n =
+        Math.min(
+            this.size(),
+            that.size());
+    for (int i = 0; i < n; i++) {
+      RelTrait thisTrait = this.traits[i];
+      RelTrait thatTrait = that.traits[i];
+      if (!thisTrait.satisfies(thatTrait)) {
         return false;
       }
     }
@@ -503,9 +508,16 @@ public final class RelTraitSet extends 
AbstractList<RelTrait> {
    * RelTraitSet. */
   public ImmutableList<RelTrait> difference(RelTraitSet traitSet) {
     final ImmutableList.Builder<RelTrait> builder = ImmutableList.builder();
-    for (Pair<RelTrait, RelTrait> pair : Pair.zip(traits, traitSet.traits)) {
-      if (pair.left != pair.right) {
-        builder.add(pair.right);
+    final int n =
+        Math.min(
+            this.size(),
+            traitSet.size());
+
+    for (int i = 0; i < n; i++) {
+      RelTrait thisTrait = this.traits[i];
+      RelTrait thatTrait = traitSet.traits[i];
+      if (thisTrait != thatTrait) {
+        builder.add(thatTrait);
       }
     }
     return builder.build();

Reply via email to