Github user aweisberg commented on a diff in the pull request:
https://github.com/apache/cassandra/pull/224#discussion_r188110522
--- Diff: src/java/org/apache/cassandra/locator/ReplicaList.java ---
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.locator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Predicate;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
+public class ReplicaList extends Replicas
+{
+ static final ReplicaList EMPTY = new ReplicaList(ImmutableList.of());
+
+ private final List<Replica> replicaList;
+
+ public ReplicaList()
+ {
+ replicaList = new ArrayList<>();
+ }
+
+ public ReplicaList(int capacity)
+ {
+ replicaList = new ArrayList<>(capacity);
+ }
+
+ public ReplicaList(ReplicaList from)
+ {
+ replicaList = new ArrayList<>(from.replicaList);
+ }
+
+ public ReplicaList(Replicas from)
+ {
+ replicaList = new ArrayList<>(from.size());
+ addAll(from);
+ }
+
+ public ReplicaList(Collection<Replica> from)
+ {
+ replicaList = new ArrayList<>(from);
+ }
+
+ private ReplicaList(List<Replica> replicaList)
+ {
+ this.replicaList = replicaList;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ReplicaList that = (ReplicaList) o;
+ return Objects.equals(replicaList, that.replicaList);
+ }
+
+ public int hashCode()
+ {
+
+ return Objects.hash(replicaList);
--- End diff --
replicaList is not null so I would have just used replicaList.hashCode().
This might allocate a wrapper array for varargs.
Objects.hashCode() is the single arg version that won't allocate.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]