aherbert commented on code in PR #335:
URL: https://github.com/apache/commons-math/pull/335#discussion_r4370695839


##########
commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/IntegerSequence.java:
##########
@@ -361,20 +367,20 @@ public void increment(int nTimes) throws 
MaxCountExceededException {
                 throw new NotStrictlyPositiveException(nTimes);
             }
 
-            if (!canIncrement()) {
+            if (exhausted) {
                 maxCountCallback.trigger(maximalCount);
                 return;
             }
 
             final long newCount = count + (long) nTimes * increment;
-            if (increment < 0 ? newCount <= maximalCount : newCount >= 
maximalCount) {
+            if (isExhausted(newCount)) {
                 count = maximalCount;
                 exhausted = true;
             } else {
                 count = newCount;
             }
 
-            if (!canIncrement()) {
+            if (isExhausted(newCount) || isExhausted(newCount - increment)) {

Review Comment:
   Replace `isExhausted(newCount)` with `exhausted`



##########
commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/IntegerSequence.java:
##########


Review Comment:
   Can you fix this javadoc. It refers to nTimes which is not related to this 
method.
   
   I think the javadoc is wrong. It should state that the result is true if the 
counter is not exhausted, i.e. the count is below the configured maximum. A 
call to increment is allowed but it may trigger the max count callback if the 
next increment causes the count to reach the configured limit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to