ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [06/12] ignite git commit: ignite-gg-12163 utils update nearestPow2
Date Mon, 29 May 2017 07:56:33 GMT
ignite-gg-12163 utils update nearestPow2


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/874096f3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/874096f3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/874096f3

Branch: refs/heads/ignite-5075-pds
Commit: 874096f33a68e61d96dfce2ef3af0f354b4ce102
Parents: 68ee063
Author: Dmitriy Govorukhin <dmitriy.govorukhin@gmail.com>
Authored: Fri May 26 11:54:59 2017 +0300
Committer: Dmitriy Govorukhin <dmitriy.govorukhin@gmail.com>
Committed: Fri May 26 11:54:59 2017 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/internal/util/IgniteUtils.java    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/874096f3/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 555238f..90de683 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -10197,10 +10197,16 @@ public abstract class IgniteUtils {
      * @param less Less.
      */
     public static int nearestPow2(int x, boolean less) {
+        assert x > 0 : "can not calculate for less zero";
+
         int y = 1;
 
-        while (y < x)
+        while (y < x){
+            if ((long)y * 2 > Integer.MAX_VALUE)
+                return y;
+
             y *= 2;
+        }
 
         if (less)
             y /= 2;


Mime
View raw message