[ 
https://issues.apache.org/jira/browse/LANG-1548?focusedWorklogId=441844&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-441844
 ]

ASF GitHub Bot logged work on LANG-1548:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Jun/20 14:49
            Start Date: 05/Jun/20 14:49
    Worklog Time Spent: 10m 
      Work Description: XenoAmess commented on a change in pull request #534:
URL: https://github.com/apache/commons-lang/pull/534#discussion_r435717449



##########
File path: src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
##########
@@ -252,17 +252,58 @@ static int lastIndexOf(final CharSequence cs, final 
CharSequence searchChar, fin
      * Green implementation of regionMatches.
      *
      * @param cs the {@code CharSequence} to be processed
-     * @param ignoreCase whether or not to be case insensitive
      * @param thisStart the index to start on the {@code cs} CharSequence
      * @param substring the {@code CharSequence} to be looked for
      * @param start the index to start on the {@code substring} CharSequence
      * @param length character length of the region
      * @return whether the region matched
      */
-    static boolean regionMatches(final CharSequence cs, final boolean 
ignoreCase, final int thisStart,
-            final CharSequence substring, final int start, final int length)   
 {
+    static boolean regionMatches(final CharSequence cs, final int thisStart,
+                                 final CharSequence substring, final int 
start, final int length)    {
+        if (cs instanceof String && substring instanceof String) {
+            return ((String) cs).regionMatches(thisStart, (String) substring, 
start, length);
+        }
+        int index1 = thisStart;
+        int index2 = start;
+        int tmpLen = length;
+
+        // Extract these first so we detect NPEs the same as the 
java.lang.String version
+        final int srcLen = cs.length() - thisStart;
+        final int otherLen = substring.length() - start;
+
+        // Check for invalid parameters
+        if (thisStart < 0 || start < 0 || length < 0) {
+            return false;
+        }
+
+        // Check that the regions are long enough
+        if (srcLen < length || otherLen < length) {
+            return false;
+        }
+
+        while (tmpLen-- > 0) {

Review comment:
       @dota17
   the `while (tmpLen-- > 0) {` is same as it in original codes.
   I just want to make as less changes as possible.
   If you think we should reformat the codes I feel like agreed, but lets' do 
that after this pr, or at least, when merging this pr.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 441844)
    Time Spent: 2h 50m  (was: 2h 40m)

> split regionMatches for better performance
> ------------------------------------------
>
>                 Key: LANG-1548
>                 URL: https://issues.apache.org/jira/browse/LANG-1548
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: JIN XU
>            Priority: Minor
>          Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> [https://github.com/apache/commons-lang/pull/534/files]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to