inefficient indexof when String has one length

Paul Sandoz paul.sandoz at oracle.com
Mon May 12 16:56:09 UTC 2014


On Apr 26, 2014, at 12:56 PM, Otávio Gonçalves de Santana <otaviojava at java.net> wrote:
> When a String has length just one, could be replaced by equivalent
> character literals, gaining some performance enhancement.
> 
> I found 107 changes.
> 

This looks good to me, just one small issue:

--- a/src/share/classes/javax/security/auth/PrivateCredentialPermission.java	Wed Apr 23 11:35:40 2014 -0700
+++ b/src/share/classes/javax/security/auth/PrivateCredentialPermission.java	Sat Apr 26 07:31:04 2014 -0300
@@ -495,7 +495,7 @@
 
         // perform new initialization from the permission name
 
-        if (getName().indexOf(" ") == -1 && getName().indexOf("\"") == -1) {
+        if (getName().indexOf(' ') == -1 && getName().indexOf('\"') == -1) {

You no longer need to escape the double quote.

Can someone else sponsor this? unfortunately i do not have the time at the moment.

Paul.



More information about the core-libs-dev mailing list