8226831: Use Objects.equals() when appropriate

Reviewed-by: rriggs, bpb
This commit is contained in:
Ivan Gerasimov 2019-08-27 14:44:21 -07:00
parent 99bf89c581
commit 3ed845784d
7 changed files with 26 additions and 31 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -311,8 +311,7 @@ public class TreeMap<K,V>
public void putAll(Map<? extends K, ? extends V> map) {
int mapSize = map.size();
if (size==0 && mapSize!=0 && map instanceof SortedMap) {
Comparator<?> c = ((SortedMap<?,?>)map).comparator();
if (c == comparator || (c != null && c.equals(comparator))) {
if (Objects.equals(comparator, ((SortedMap<?,?>)map).comparator())) {
++modCount;
try {
buildFromSorted(mapSize, map.entrySet().iterator(),