Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a09b4d2a authored by Narayan Kamath's avatar Narayan Kamath
Browse files

Remove unnecessary allocation+unboxing of objects.

Transforming String->int can be done with 0 allocations
using Integer.parseInt.

bug: 28078871
Change-Id: I8d9f322d7154728849dde61ef282046032858d60
parent 988a20a9
Loading
Loading
Loading
Loading
+27 −27
Original line number Diff line number Diff line
@@ -1790,7 +1790,7 @@ public class Am extends BaseCommand {

    private void runStackStart() throws Exception {
        String displayIdStr = nextArgRequired();
        int displayId = Integer.valueOf(displayIdStr);
        int displayId = Integer.parseInt(displayIdStr);
        Intent intent = makeIntent(UserHandle.USER_CURRENT);

        try {
@@ -1804,9 +1804,9 @@ public class Am extends BaseCommand {

    private void runStackMoveTask() throws Exception {
        String taskIdStr = nextArgRequired();
        int taskId = Integer.valueOf(taskIdStr);
        int taskId = Integer.parseInt(taskIdStr);
        String stackIdStr = nextArgRequired();
        int stackId = Integer.valueOf(stackIdStr);
        int stackId = Integer.parseInt(stackIdStr);
        String toTopStr = nextArgRequired();
        final boolean toTop;
        if ("true".equals(toTopStr)) {
@@ -1826,7 +1826,7 @@ public class Am extends BaseCommand {

    private void runStackResize() throws Exception {
        String stackIdStr = nextArgRequired();
        int stackId = Integer.valueOf(stackIdStr);
        int stackId = Integer.parseInt(stackIdStr);
        final Rect bounds = getBounds();
        if (bounds == null) {
            System.err.println("Error: invalid input bounds");
@@ -1837,7 +1837,7 @@ public class Am extends BaseCommand {

    private void runStackResizeAnimated() throws Exception {
        String stackIdStr = nextArgRequired();
        int stackId = Integer.valueOf(stackIdStr);
        int stackId = Integer.parseInt(stackIdStr);
        final Rect bounds;
        if ("null".equals(mArgs.peekNextArg())) {
            bounds = null;
@@ -1886,11 +1886,11 @@ public class Am extends BaseCommand {

    private void runStackPositionTask() throws Exception {
        String taskIdStr = nextArgRequired();
        int taskId = Integer.valueOf(taskIdStr);
        int taskId = Integer.parseInt(taskIdStr);
        String stackIdStr = nextArgRequired();
        int stackId = Integer.valueOf(stackIdStr);
        int stackId = Integer.parseInt(stackIdStr);
        String positionStr = nextArgRequired();
        int position = Integer.valueOf(positionStr);
        int position = Integer.parseInt(positionStr);

        try {
            mAm.positionTaskInStack(taskId, stackId, position);
@@ -1911,7 +1911,7 @@ public class Am extends BaseCommand {
    private void runStackInfo() throws Exception {
        try {
            String stackIdStr = nextArgRequired();
            int stackId = Integer.valueOf(stackIdStr);
            int stackId = Integer.parseInt(stackIdStr);
            StackInfo info = mAm.getStackInfo(stackId);
            System.out.println(info);
        } catch (RemoteException e) {
@@ -1920,12 +1920,12 @@ public class Am extends BaseCommand {

    private void runStackRemove() throws Exception {
        String stackIdStr = nextArgRequired();
        int stackId = Integer.valueOf(stackIdStr);
        int stackId = Integer.parseInt(stackIdStr);
        mAm.removeStack(stackId);
    }

    private void runMoveTopActivityToPinnedStack() throws Exception {
        int stackId = Integer.valueOf(nextArgRequired());
        int stackId = Integer.parseInt(nextArgRequired());
        final Rect bounds = getBounds();
        if (bounds == null) {
            System.err.println("Error: invalid input bounds");
@@ -1943,10 +1943,10 @@ public class Am extends BaseCommand {
    }

    private void runStackSizeDockedStackTest() throws Exception {
        final int stepSize = Integer.valueOf(nextArgRequired());
        final int stepSize = Integer.parseInt(nextArgRequired());
        final String side = nextArgRequired();
        final String delayStr = nextArg();
        final int delayMs = (delayStr != null) ? Integer.valueOf(delayStr) : 0;
        final int delayMs = (delayStr != null) ? Integer.parseInt(delayStr) : 0;

        Rect bounds;
        try {
@@ -2060,7 +2060,7 @@ public class Am extends BaseCommand {
            if (taskIdStr.equals("stop")) {
                mAm.stopLockTaskMode();
            } else {
                int taskId = Integer.valueOf(taskIdStr);
                int taskId = Integer.parseInt(taskIdStr);
                mAm.startLockTaskMode(taskId);
            }
            System.err.println("Activity manager is " + (mAm.isInLockTaskMode() ? "" : "not ") +
@@ -2071,9 +2071,9 @@ public class Am extends BaseCommand {

    private void runTaskResizeable() throws Exception {
        final String taskIdStr = nextArgRequired();
        final int taskId = Integer.valueOf(taskIdStr);
        final int taskId = Integer.parseInt(taskIdStr);
        final String resizeableStr = nextArgRequired();
        final int resizeableMode = Integer.valueOf(resizeableStr);
        final int resizeableMode = Integer.parseInt(resizeableStr);

        try {
            mAm.setTaskResizeable(taskId, resizeableMode);
@@ -2083,7 +2083,7 @@ public class Am extends BaseCommand {

    private void runTaskResize() throws Exception {
        final String taskIdStr = nextArgRequired();
        final int taskId = Integer.valueOf(taskIdStr);
        final int taskId = Integer.parseInt(taskIdStr);
        final Rect bounds = getBounds();
        if (bounds == null) {
            System.err.println("Error: invalid input bounds");
@@ -2104,10 +2104,10 @@ public class Am extends BaseCommand {
    }

    private void runTaskDragTaskTest() {
        final int taskId = Integer.valueOf(nextArgRequired());
        final int stepSize = Integer.valueOf(nextArgRequired());
        final int taskId = Integer.parseInt(nextArgRequired());
        final int stepSize = Integer.parseInt(nextArgRequired());
        final String delayStr = nextArg();
        final int delay_ms = (delayStr != null) ? Integer.valueOf(delayStr) : 0;
        final int delay_ms = (delayStr != null) ? Integer.parseInt(delayStr) : 0;
        final StackInfo stackInfo;
        Rect taskBounds;
        try {
@@ -2203,10 +2203,10 @@ public class Am extends BaseCommand {
    }

    private void runTaskSizeTaskTest() {
        final int taskId = Integer.valueOf(nextArgRequired());
        final int stepSize = Integer.valueOf(nextArgRequired());
        final int taskId = Integer.parseInt(nextArgRequired());
        final int stepSize = Integer.parseInt(nextArgRequired());
        final String delayStr = nextArg();
        final int delay_ms = (delayStr != null) ? Integer.valueOf(delayStr) : 0;
        final int delay_ms = (delayStr != null) ? Integer.parseInt(delayStr) : 0;
        final StackInfo stackInfo;
        final Rect initialTaskBounds;
        try {
@@ -2550,13 +2550,13 @@ public class Am extends BaseCommand {

    private Rect getBounds() {
        String leftStr = nextArgRequired();
        int left = Integer.valueOf(leftStr);
        int left = Integer.parseInt(leftStr);
        String topStr = nextArgRequired();
        int top = Integer.valueOf(topStr);
        int top = Integer.parseInt(topStr);
        String rightStr = nextArgRequired();
        int right = Integer.valueOf(rightStr);
        int right = Integer.parseInt(rightStr);
        String bottomStr = nextArgRequired();
        int bottom = Integer.valueOf(bottomStr);
        int bottom = Integer.parseInt(bottomStr);
        if (left < 0) {
            System.err.println("Error: bad left arg: " + leftStr);
            return null;
+1 −1
Original line number Diff line number Diff line
@@ -8905,7 +8905,7 @@ public class Intent implements Parcelable, Cloneable {
            } else if (ATTR_COMPONENT.equals(attrName)) {
                intent.setComponent(ComponentName.unflattenFromString(attrValue));
            } else if (ATTR_FLAGS.equals(attrName)) {
                intent.setFlags(Integer.valueOf(attrValue, 16));
                intent.setFlags(Integer.parseInt(attrValue, 16));
            } else {
                Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
            }
+1 −1
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ public final class CameraManager {
                        " currently connected camera device", cameraId));
            }

            int id = Integer.valueOf(cameraId);
            int id = Integer.parseInt(cameraId);

            /*
             * Get the camera characteristics from the camera service directly if it supports it,
+1 −1
Original line number Diff line number Diff line
@@ -428,7 +428,7 @@ public final class NfcFCardEmulation {
            return false;
        }
        try {
            Integer.valueOf(systemCode, 16);
            Integer.parseInt(systemCode, 16);
        } catch (NumberFormatException e) {
            Log.e(TAG, "System Code " + systemCode + " is not a valid System Code.");
            return false;
+2 −2
Original line number Diff line number Diff line
@@ -1163,7 +1163,7 @@ public final class StrictMode {
        }
        String policyString = message.substring(7, spaceIndex);
        try {
            return Integer.valueOf(policyString).intValue();
            return Integer.parseInt(policyString);
        } catch (NumberFormatException e) {
            return 0;
        }
@@ -1187,7 +1187,7 @@ public final class StrictMode {
        }
        String violationString = message.substring(numberStartIndex, numberEndIndex);
        try {
            return Integer.valueOf(violationString).intValue();
            return Integer.parseInt(violationString);
        } catch (NumberFormatException e) {
            return 0;
        }
Loading