You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2015/11/10 23:07:42 UTC

[math] Avoid explicit instantiation of "Integer" objects for small values.

Repository: commons-math
Updated Branches:
  refs/heads/master 396610625 -> 268bcd622


Avoid explicit instantiation of "Integer" objects for small values.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/268bcd62
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/268bcd62
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/268bcd62

Branch: refs/heads/master
Commit: 268bcd622685b28c2d50bcbce64ac38f7e90390b
Parents: 3966106
Author: Gilles <er...@apache.org>
Authored: Tue Nov 10 23:05:27 2015 +0100
Committer: Gilles <er...@apache.org>
Committed: Tue Nov 10 23:05:27 2015 +0100

----------------------------------------------------------------------
 .../math4/distribution/EnumeratedIntegerDistribution.java      | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/268bcd62/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java b/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java
index 8cdf8e1..e0843eb 100644
--- a/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/EnumeratedIntegerDistribution.java
@@ -115,11 +115,9 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
         for (int value : data) {
             Integer count = dataMap.get(value);
             if (count == null) {
-                count = new Integer(1);
-            } else {
-                count = new Integer(count.intValue() + 1);
+                count = 0;
             }
-            dataMap.put(value, count);
+            dataMap.put(value, ++count);
         }
         final int massPoints = dataMap.size();
         final double denom = data.length;