Remove unnecessary allocation+unboxing of objects.
Transforming String->int can be done with 0 allocations
using Integer.parseInt.
bug: 28078871
Change-Id: I8d9f322d7154728849dde61ef282046032858d60
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 544e645..79d16da 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -2473,7 +2473,7 @@
int subtypeId = NOT_A_SUBTYPE_ID;
if (lastIme != null && lastImi != null) {
final boolean imiIdIsSame = lastImi.getId().equals(mCurMethodId);
- final int lastSubtypeHash = Integer.valueOf(lastIme.second);
+ final int lastSubtypeHash = Integer.parseInt(lastIme.second);
final int currentSubtypeHash = mCurrentSubtype == null ? NOT_A_SUBTYPE_ID
: mCurrentSubtype.hashCode();
// If the last IME is the same as the current IME and the last subtype is not
@@ -2587,7 +2587,7 @@
final InputMethodInfo lastImi = mMethodMap.get(lastIme.first);
if (lastImi == null) return null;
try {
- final int lastSubtypeHash = Integer.valueOf(lastIme.second);
+ final int lastSubtypeHash = Integer.parseInt(lastIme.second);
final int lastSubtypeId =
InputMethodUtils.getSubtypeIdFromHashCode(lastImi, lastSubtypeHash);
if (lastSubtypeId < 0 || lastSubtypeId >= lastImi.getSubtypeCount()) {
@@ -3437,7 +3437,7 @@
if (subtypeHashCode != null) {
try {
lastSubtypeId = InputMethodUtils.getSubtypeIdFromHashCode(
- imi, Integer.valueOf(subtypeHashCode));
+ imi, Integer.parseInt(subtypeHashCode));
} catch (NumberFormatException e) {
Slog.w(TAG, "HashCode for subtype looks broken: " + subtypeHashCode, e);
}
@@ -3798,9 +3798,9 @@
Slog.w(TAG, "IME uninstalled or not valid.: " + currentImiId);
continue;
}
- final int icon = Integer.valueOf(
+ final int icon = Integer.parseInt(
parser.getAttributeValue(null, ATTR_ICON));
- final int label = Integer.valueOf(
+ final int label = Integer.parseInt(
parser.getAttributeValue(null, ATTR_LABEL));
final String imeSubtypeLocale =
parser.getAttributeValue(null, ATTR_IME_SUBTYPE_LOCALE);
@@ -3826,7 +3826,7 @@
final String subtypeIdString =
parser.getAttributeValue(null, ATTR_IME_SUBTYPE_ID);
if (subtypeIdString != null) {
- builder.setSubtypeId(Integer.valueOf(subtypeIdString));
+ builder.setSubtypeId(Integer.parseInt(subtypeIdString));
}
tempSubtypesArray.add(builder.build());
}