]> source.dussan.org Git - aspectj.git/commitdiff
Cleanup redundant boxing. 103/head
authorAndrey Turbanov <turbanoff@gmail.com>
Sat, 20 Nov 2021 17:37:02 +0000 (20:37 +0300)
committerAndrey Turbanov <turbanoff@gmail.com>
Sat, 20 Nov 2021 17:37:02 +0000 (20:37 +0300)
Methods Integer.parseInt/Boolean.parseBoolean should be preferred over Integer.valueOf/Boolean.valueOf/ if final result is primitive.
They are generally faster and generate less garbage.

asm/src/main/java/org/aspectj/asm/internal/JDTLikeHandleProvider.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/IncrementalCase.java
org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/TraceFactory.java
testing/src/test/java/org/aspectj/testing/harness/bridge/FlatSuiteReader.java
testing/src/test/java/org/aspectj/testing/harness/bridge/ParseTestCase.java
testing/src/test/java/org/aspectj/testing/xml/SoftMessage.java
testing/src/test/java/org/aspectj/testing/xml/SoftSourceLocation.java
util/src/main/java/org/aspectj/util/LangUtil.java

index 0c82714415bcff5f843de0c8fbe7ac24f1097c70..215a00f3b0b1171b6b88a446944ed9122021e8a2 100644 (file)
@@ -227,7 +227,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider {
                                                        String existingHandle = object.getHandleIdentifier();
                                                        int suffixPosition = existingHandle.indexOf('!');
                                                        if (suffixPosition != -1) {
-                                                               count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1;
+                                                               count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1;
                                                        } else {
                                                                if (count == 1) {
                                                                        count = 2;
@@ -279,7 +279,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider {
                                                        String existingHandle = object.getHandleIdentifier();
                                                        int suffixPosition = existingHandle.indexOf('!');
                                                        if (suffixPosition != -1) {
-                                                               count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1;
+                                                               count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1;
                                                        } else {
                                                                if (count == 1) {
                                                                        count = 2;
@@ -314,7 +314,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider {
                                                        int suffixPosition = existingHandle.lastIndexOf('!');
                                                        int lastSquareBracket = existingHandle.lastIndexOf('['); // type delimiter
                                                        if (suffixPosition != -1 && lastSquareBracket < suffixPosition) { // pr260384
-                                                               count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1;
+                                                               count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1;
                                                        } else {
                                                                if (count == 1) {
                                                                        count = 2;
@@ -334,7 +334,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider {
                                                        int suffixPosition = existingHandle.lastIndexOf('!');
                                                        int lastSquareBracket = existingHandle.lastIndexOf('['); // type delimiter
                                                        if (suffixPosition != -1 && lastSquareBracket < suffixPosition) { // pr260384
-                                                               count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1;
+                                                               count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1;
                                                        } else {
                                                                if (count == 1) {
                                                                        count = 2;
@@ -383,7 +383,7 @@ public class JDTLikeHandleProvider implements IElementHandleProvider {
                                        String existingHandle = object.getHandleIdentifier();
                                        int suffixPosition = existingHandle.indexOf('!');
                                        if (suffixPosition != -1) {
-                                               count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1;
+                                               count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1;
                                        } else {
                                                if (count == 1) {
                                                        count = 2;
index 96c959970691925e7c984a434573127ab9fda481..cf753b8c61485c60b5674a6b4445346fbc4367c2 100644 (file)
@@ -311,7 +311,7 @@ public class IncrementalCase { // XXX NOT bound to junit - bridge tests?
                        if (-1 != loc)
                                s = s.substring(loc + 1);
                        try {
-                               exp[i] = Integer.valueOf(s);
+                               exp[i] = Integer.parseInt(s);
                                sb.append(exp[i] + ((i < (exp.length - 1)) ? ", " : ""));
                        } catch (NumberFormatException e) {
                                info(handler, "bad " + label + ":" + expected[i]);
index 35bd22c683f37320825a3ab74e3c47f2e24f47c4..d5df010795eedced4e6d0ab137074f8051ae46c2 100644 (file)
@@ -1041,7 +1041,7 @@ public abstract class AjcTestCase extends TestCase {
        private static boolean getBoolean(String name, boolean def) {
                String defaultValue = String.valueOf(def);
                String value = System.getProperty(name, defaultValue);
-               return Boolean.valueOf(value);
+               return Boolean.parseBoolean(value);
        }
 
        /*
index 8154636534de5cbcb9ba9fa4b5cdb76069503eb6..245dc2e4d9a6d4ecf17fdae29b85cc18dab9802b 100644 (file)
@@ -30,7 +30,7 @@ public abstract class TraceFactory {
     protected static boolean getBoolean(String name, boolean def) {
                String defaultValue = String.valueOf(def);
                String value = System.getProperty(name,defaultValue);
-               return Boolean.valueOf(value);
+               return Boolean.parseBoolean(value);
        }
 
        static {
index 0b9d6910e986c1d085ea41aea3c9b9c7d0eb7901..5c2ec2ae35eb657f85bd54520803c35bbe0c4378 100644 (file)
@@ -267,7 +267,7 @@ public class FlatSuiteReader implements SFileReader.Maker {
             description.setLength(0);
             description.append((prefix + " " + suffix).trim());
             try {
-                result.setBugId(Integer.valueOf(pr));
+                result.setBugId(Integer.parseInt(pr));
             } catch (NumberFormatException e) {
                 throw new Error("unable to convert " + pr + " for " + result
                     + " at " + lineReader);
index 85cdd38f181648e4f28e0629b5a90f4c1130a236..e6f1ab91816d1b12d5c2e937de9a9ee3706f100e 100644 (file)
@@ -105,7 +105,7 @@ public class ParseTestCase extends TestCase {
         AjcTest.Spec test = new AjcTest.Spec();
         test.setDescription(title);
         test.setTestDirOffset(dir);
-        test.setBugId(Integer.valueOf(pr));
+        test.setBugId(Integer.parseInt(pr));
         test.setSourceLocation(sourceLocation);
                //AjcTest test = new AjcTest(title, dir, pr, sourceLocation);
 
@@ -174,7 +174,7 @@ public class ParseTestCase extends TestCase {
                        file = new File("XXX");  //XXX
                }
 
-               int line = Integer.valueOf(getAttributeString(child, "line"));
+               int line = Integer.parseInt(getAttributeString(child, "line"));
 
                ISourceLocation sourceLocation = new SourceLocation(file, line, line, 0);
 
index a223a3453b354287ab53d9a971edb3f6264cbb2d..be3541e4d89ee0e879b7954ea5c9f65257c57afb 100644 (file)
@@ -300,7 +300,7 @@ public class SoftMessage implements IMessage {
                if (null != sourceLocation) {
                        throw new IllegalStateException("cannot set line after creating source location");
                }
-               this.line = Integer.valueOf(line);
+               this.line = Integer.parseInt(line);
                SourceLocation.validLine(this.line);
        }
 
index 305047d31d50b16cbd0f911bbdbb187533773557..f0329d6531eca0e32416ac277cb1e94623646321 100644 (file)
@@ -109,7 +109,7 @@ public class SoftSourceLocation implements ISourceLocation  {
     }
 
     private int convert(String in) {
-        return Integer.valueOf(in);
+        return Integer.parseInt(in);
     }
 
        public String getLocationContext() {
index 187b895b29bacf066bd89b4e34af84309f9d4bfd..cfe9a0bea9e9be003fa194212c70128a94465dac 100644 (file)
@@ -353,7 +353,7 @@ public class LangUtil {
                        try {
                                String value = System.getProperty(propertyName);
                                if (null != value) {
-                                       return Boolean.valueOf(value);
+                                       return Boolean.parseBoolean(value);
                                }
                        } catch (Throwable t) {
                                // default below