"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spring-core/src/main/java/org/springframework/util/CollectionUtils.java" between
spring-framework-5.3.23.tar.gz and spring-framework-5.3.24.tar.gz

About: Spring Framework is an application framework for the Java platform and .NET Framework. Community edition.

CollectionUtils.java  (spring-framework-5.3.23):CollectionUtils.java  (spring-framework-5.3.24)
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
skipping to change at line 87 skipping to change at line 87
* <p>This differs from the regular {@link HashMap} constructor * <p>This differs from the regular {@link HashMap} constructor
* which takes an initial capacity relative to a load factor * which takes an initial capacity relative to a load factor
* but is effectively aligned with the JDK's * but is effectively aligned with the JDK's
* {@link java.util.concurrent.ConcurrentHashMap#ConcurrentHashMap(int)}. * {@link java.util.concurrent.ConcurrentHashMap#ConcurrentHashMap(int)}.
* @param expectedSize the expected number of elements (with a correspond ing * @param expectedSize the expected number of elements (with a correspond ing
* capacity to be derived so that no resize/rehash operations are needed) * capacity to be derived so that no resize/rehash operations are needed)
* @since 5.3 * @since 5.3
* @see #newLinkedHashMap(int) * @see #newLinkedHashMap(int)
*/ */
public static <K, V> HashMap<K, V> newHashMap(int expectedSize) { public static <K, V> HashMap<K, V> newHashMap(int expectedSize) {
return new HashMap<>((int) (expectedSize / DEFAULT_LOAD_FACTOR), DEFAULT_LOAD_FACTOR); return new HashMap<>(computeMapInitialCapacity(expectedSize), DEF AULT_LOAD_FACTOR);
} }
/** /**
* Instantiate a new {@link LinkedHashMap} with an initial capacity * Instantiate a new {@link LinkedHashMap} with an initial capacity
* that can accommodate the specified number of elements without * that can accommodate the specified number of elements without
* any immediate resize/rehash operations to be expected. * any immediate resize/rehash operations to be expected.
* <p>This differs from the regular {@link LinkedHashMap} constructor * <p>This differs from the regular {@link LinkedHashMap} constructor
* which takes an initial capacity relative to a load factor but is * which takes an initial capacity relative to a load factor but is
* aligned with Spring's own {@link LinkedCaseInsensitiveMap} and * aligned with Spring's own {@link LinkedCaseInsensitiveMap} and
* {@link LinkedMultiValueMap} constructor semantics as of 5.3. * {@link LinkedMultiValueMap} constructor semantics as of 5.3.
* @param expectedSize the expected number of elements (with a correspond ing * @param expectedSize the expected number of elements (with a correspond ing
* capacity to be derived so that no resize/rehash operations are needed) * capacity to be derived so that no resize/rehash operations are needed)
* @since 5.3 * @since 5.3
* @see #newHashMap(int) * @see #newHashMap(int)
*/ */
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(int expectedSiz e) { public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(int expectedSiz e) {
return new LinkedHashMap<>((int) (expectedSize / DEFAULT_LOAD_FAC return new LinkedHashMap<>(computeMapInitialCapacity(expectedSize
TOR), DEFAULT_LOAD_FACTOR); ), DEFAULT_LOAD_FACTOR);
}
private static int computeMapInitialCapacity(int expectedSize) {
return (int) Math.ceil(expectedSize / (double) DEFAULT_LOAD_FACTO
R);
} }
/** /**
* Convert the supplied array into a List. A primitive array gets convert ed * Convert the supplied array into a List. A primitive array gets convert ed
* into a List of the appropriate wrapper type. * into a List of the appropriate wrapper type.
* <p><b>NOTE:</b> Generally prefer the standard {@link Arrays#asList} me thod. * <p><b>NOTE:</b> Generally prefer the standard {@link Arrays#asList} me thod.
* This {@code arrayToList} method is just meant to deal with an incoming Object * This {@code arrayToList} method is just meant to deal with an incoming Object
* value that might be an {@code Object[]} or a primitive array at runtim e. * value that might be an {@code Object[]} or a primitive array at runtim e.
* <p>A {@code null} source value will be converted to an empty List. * <p>A {@code null} source value will be converted to an empty List.
* @param source the (potentially primitive) array * @param source the (potentially primitive) array
 End of changes. 3 change blocks. 
4 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)