This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new e446f48 Fix wrong calculation of HashMap capacity.
e446f48 is described below
commit e446f487af6628b32ec61e7b4b4b83a05ece6a12
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon Sep 10 15:52:43 2018 +0200
Fix wrong calculation of HashMap capacity.
---
.../java/org/apache/sis/referencing/crs/AbstractCRS.java | 2 +-
.../java/org/apache/sis/util/collection/Containers.java | 14 ++++++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
index b4994ce..c76a353 100644
---
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
+++
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
@@ -461,7 +461,7 @@ public class AbstractCRS extends AbstractReferenceSystem
implements CoordinateRe
* @param formatter the formatter where to append the coordinate system.
* @param cs the coordinate system to append.
* @param unit the value of {@code
ReferencingUtilities.getUnit(cs)}.
- * @param isWKT1 { @code true} if formatting WKT 1, or {@code false}
for WKT 2.
+ * @param isWKT1 {@code true} if formatting WKT 1, or {@code false}
for WKT 2.
*/
final void formatCS(final Formatter formatter, final CoordinateSystem cs,
final Unit<?> unit, final boolean isWKT1) {
assert unit == ReferencingUtilities.getUnit(cs) : unit;
diff --git
a/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
b/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
index 9d5a1c7..5bdce5a 100644
---
a/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
+++
b/core/sis-utility/src/main/java/org/apache/sis/util/collection/Containers.java
@@ -263,11 +263,17 @@ public final class Containers extends Static {
* @return the minimal initial capacity to be given to the hash map
constructor.
*/
public static int hashMapCapacity(final int count) {
- int r = count >>> 2;
- if ((count & 0x3) != 0) {
- r++;
+ if (count > 0) {
+ /*
+ * Dividing 'count' by 0.75 is equivalent to multiplying by
1.333333…
+ */
+ int r = count / 3;
+ if ((count % 3) != 0) {
+ r++;
+ }
+ return count + r;
}
- return count + r;
+ return 0;
}
/**