You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/06/13 21:39:14 UTC

[commons-text] branch master updated: Use Math.min() call instead of doing it manually. (#335)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git


The following commit(s) were added to refs/heads/master by this push:
     new baee3346 Use Math.min() call instead of doing it manually. (#335)
baee3346 is described below

commit baee3346849ad6da8a8179bca40f311ceec4d992
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Mon Jun 13 23:39:09 2022 +0200

    Use Math.min() call instead of doing it manually. (#335)
---
 src/main/java/org/apache/commons/text/WordUtils.java | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/WordUtils.java b/src/main/java/org/apache/commons/text/WordUtils.java
index 561f1afe..accd436f 100644
--- a/src/main/java/org/apache/commons/text/WordUtils.java
+++ b/src/main/java/org/apache/commons/text/WordUtils.java
@@ -104,11 +104,7 @@ public class WordUtils {
                 result.append(StringUtils.defaultString(appendToEnd));
             }
         } else {
-            if (index > upper) {
-                result.append(str, 0, upper);
-            } else {
-                result.append(str, 0, index);
-            }
+            result.append(str, 0, Math.min(index, upper));
             result.append(StringUtils.defaultString(appendToEnd));
         }