[ 
https://issues.apache.org/jira/browse/MYFACES-4249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16570674#comment-16570674
 ] 

ASF GitHub Bot commented on MYFACES-4249:
-----------------------------------------

pnicolucci closed pull request #15: MYFACES-4249: Don't call charAt more than 
needed
URL: https://github.com/apache/myfaces/pull/15
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/impl/src/main/java/org/apache/myfaces/util/CDataEndEscapeFilterWriter.java 
b/impl/src/main/java/org/apache/myfaces/util/CDataEndEscapeFilterWriter.java
index 155d17882..a72403036 100644
--- a/impl/src/main/java/org/apache/myfaces/util/CDataEndEscapeFilterWriter.java
+++ b/impl/src/main/java/org/apache/myfaces/util/CDataEndEscapeFilterWriter.java
@@ -69,7 +69,7 @@ public void write(char[] cbuf, int off, int len) throws 
IOException
                 out.write("<![CDATA[]]]]><![CDATA[>");
             }
             c1 = c2;
-            c2 = (char) cbuf[off+i];
+            c2 = c;
             pos++;
         }
         if (index < off+len)
@@ -92,7 +92,7 @@ public void write(String str, int off, int len) throws 
IOException
                 out.write("<![CDATA[]]]]><![CDATA[>");
             }
             c1 = c2;
-            c2 = (char) str.charAt(off+i);
+            c2 = c;
             pos++;
         }
         if (index < off+len)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


> [perf] minor change in CDataEndEscapeFilterWriter to not call str.charAt 
> multiple times
> ---------------------------------------------------------------------------------------
>
>                 Key: MYFACES-4249
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4249
>             Project: MyFaces Core
>          Issue Type: Improvement
>    Affects Versions: 2.2.12, 2.3.1
>            Reporter: Paul Nicolucci
>            Assignee: Paul Nicolucci
>            Priority: Minor
>             Fix For: 2.2.13, 2.3.2
>
>
> Currently we calll             c2 = (char) str.charAt(off+i); when (char) 
> str.charAt(off+i) was previously stored in the write method to variable c so 
> we can easily just do the following c2=c and save some string manipulation.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to