You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2022/06/25 08:14:12 UTC

[myfaces] branch master updated: Replace minimum and the maximum of two numbers with Math.max() or Math.min() call instead of doing it manually. (#278)

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

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new 1fe808cea Replace minimum and the maximum of two numbers with Math.max() or Math.min() call instead of doing it manually. (#278)
1fe808cea is described below

commit 1fe808cea71cd9e8b48723841bcf201eb3b7552a
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Sat Jun 25 10:14:08 2022 +0200

    Replace minimum and the maximum of two numbers with Math.max() or Math.min() call instead of doing it manually. (#278)
---
 .../main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java | 6 +++---
 impl/src/main/java/org/apache/myfaces/util/lang/StringUtils.java    | 2 +-
 .../main/java/org/apache/myfaces/view/facelets/util/Classpath.java  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java b/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java
index 33962b5e4..deb26aa3b 100644
--- a/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java
+++ b/impl/src/main/java/org/apache/myfaces/lifecycle/RestoreViewExecutor.java
@@ -453,8 +453,8 @@ class RestoreViewExecutor extends PhaseExecutor
             if (ectx.getRequestServletPath() != null && ectx.getRequestPathInfo() != null)
             {
                 servletPathIndex = ectx.getRequestServletPath() != null ? 
-                    path.indexOf(ectx.getRequestServletPath(), 
-                                 appContextPathIndex >= 0 ? appContextPathIndex : 0) : -1;
+                    path.indexOf(ectx.getRequestServletPath(),
+                            Math.max(appContextPathIndex, 0)) : -1;
                 if (servletPathIndex != -1)
                 {
                     pathInfoIndex = servletPathIndex + ectx.getRequestServletPath().length();
@@ -463,7 +463,7 @@ class RestoreViewExecutor extends PhaseExecutor
             else
             {
                 servletPathIndex = -1;
-                pathInfoIndex = (appContextPathIndex >= 0 ? appContextPathIndex : 0) + appContextPath.length();
+                pathInfoIndex = (Math.max(appContextPathIndex, 0)) + appContextPath.length();
             }
 
             // If match appContextPath(if any) and match servletPath or pathInfo referer header is ok
diff --git a/impl/src/main/java/org/apache/myfaces/util/lang/StringUtils.java b/impl/src/main/java/org/apache/myfaces/util/lang/StringUtils.java
index f4f300170..c10b878c7 100755
--- a/impl/src/main/java/org/apache/myfaces/util/lang/StringUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/util/lang/StringUtils.java
@@ -770,6 +770,6 @@ public final class StringUtils
     {
         return (a < 0) ? b
             : (b < 0) ? a
-                : (a < b) ? a : b;
+                : Math.min(a, b);
     }
 }
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java b/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java
index 43b1bae56..99f4830bb 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/util/Classpath.java
@@ -286,7 +286,7 @@ public final class Classpath
         // Find suffix prefixed by '!' on OC4J
         int oc4jIndex = urlFile.indexOf('!');
         // Take the first found suffix
-        int separatorIndex = wlIndex == -1 && oc4jIndex == -1 ? -1 : wlIndex < oc4jIndex ? wlIndex : oc4jIndex;
+        int separatorIndex = wlIndex == -1 && oc4jIndex == -1 ? -1 : Math.min(wlIndex, oc4jIndex);
 
         if (separatorIndex != -1)
         {