frameworks/base: Avoid Long object allocations in Long.valueOf() am: 28532d0026

am: 9031ab18fd

* commit '9031ab18fdb0187016998d0e192df12160265b9c':
  frameworks/base: Avoid Long object allocations in Long.valueOf()

Change-Id: I87089a855f76ccbdb086185000f13e803023e67a
This commit is contained in:
Tobias Thierer
2016-04-22 12:58:47 +00:00
committed by android-build-merger
12 changed files with 26 additions and 26 deletions

View File

@@ -128,15 +128,15 @@ public class RequestSync {
} else if (opt.equals("--el") || opt.equals("--extra-long")) {
final String key = nextArgRequired();
final String value = nextArgRequired();
mExtras.putLong(key, Long.valueOf(value));
mExtras.putLong(key, Long.parseLong(value));
} else if (opt.equals("--ef") || opt.equals("--extra-float")) {
final String key = nextArgRequired();
final String value = nextArgRequired();
mExtras.putFloat(key, Long.valueOf(value));
mExtras.putFloat(key, Long.parseLong(value));
} else if (opt.equals("--ed") || opt.equals("--extra-double")) {
final String key = nextArgRequired();
final String value = nextArgRequired();
mExtras.putFloat(key, Long.valueOf(value));
mExtras.putFloat(key, Long.parseLong(value));
} else if (opt.equals("--ez") || opt.equals("--extra-bool")) {
final String key = nextArgRequired();
final String value = nextArgRequired();

View File

@@ -453,7 +453,7 @@ public final class NfcFCardEmulation {
return false;
}
try {
Long.valueOf(nfcid2, 16);
Long.parseLong(nfcid2, 16);
} catch (NumberFormatException e) {
Log.e(TAG, "NFCID2 " + nfcid2 + " is not a valid NFCID2.");
return false;

View File

@@ -387,7 +387,7 @@ public class ZenModeConfig implements Parcelable {
private static long tryParseLong(String value, long defValue) {
if (TextUtils.isEmpty(value)) return defValue;
try {
return Long.valueOf(value);
return Long.parseLong(value);
} catch (NumberFormatException e) {
return defValue;
}

View File

@@ -1748,7 +1748,7 @@ public class ExifInterface {
String subSecs = getAttribute(TAG_SUBSEC_TIME);
if (subSecs != null) {
try {
long sub = Long.valueOf(subSecs);
long sub = Long.parseLong(subSecs);
while (sub > 1000) {
sub /= 10;
}

View File

@@ -560,7 +560,7 @@ final class SettingsState {
}
public Setting(String name, String value, String packageName, String id) {
mNextId = Math.max(mNextId, Long.valueOf(id) + 1);
mNextId = Math.max(mNextId, Long.parseLong(id) + 1);
init(name, value, packageName, id);
}

View File

@@ -607,7 +607,7 @@ public final class DropBoxManagerService extends SystemService {
this.flags = flags;
long millis;
try { millis = Long.valueOf(name); } catch (NumberFormatException e) { millis = 0; }
try { millis = Long.parseLong(name); } catch (NumberFormatException e) { millis = 0; }
this.timestampMillis = millis;
}

View File

@@ -1394,7 +1394,7 @@ final class ActivityRecord {
if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG,
"ActivityRecord: attribute name=" + attrName + " value=" + attrValue);
if (ATTR_ID.equals(attrName)) {
createTime = Long.valueOf(attrValue);
createTime = Long.parseLong(attrValue);
} else if (ATTR_LAUNCHEDFROMUID.equals(attrName)) {
launchedFromUid = Integer.parseInt(attrValue);
} else if (ATTR_LAUNCHEDFROMPACKAGE.equals(attrName)) {

View File

@@ -1240,29 +1240,29 @@ final class TaskRecord {
rootAffinity = attrValue;
hasRootAffinity = true;
} else if (ATTR_ROOTHASRESET.equals(attrName)) {
rootHasReset = Boolean.valueOf(attrValue);
rootHasReset = Boolean.parseBoolean(attrValue);
} else if (ATTR_AUTOREMOVERECENTS.equals(attrName)) {
autoRemoveRecents = Boolean.valueOf(attrValue);
autoRemoveRecents = Boolean.parseBoolean(attrValue);
} else if (ATTR_ASKEDCOMPATMODE.equals(attrName)) {
askedCompatMode = Boolean.valueOf(attrValue);
askedCompatMode = Boolean.parseBoolean(attrValue);
} else if (ATTR_USERID.equals(attrName)) {
userId = Integer.parseInt(attrValue);
} else if (ATTR_USER_SETUP_COMPLETE.equals(attrName)) {
userSetupComplete = Boolean.valueOf(attrValue);
userSetupComplete = Boolean.parseBoolean(attrValue);
} else if (ATTR_EFFECTIVE_UID.equals(attrName)) {
effectiveUid = Integer.parseInt(attrValue);
} else if (ATTR_TASKTYPE.equals(attrName)) {
taskType = Integer.parseInt(attrValue);
} else if (ATTR_FIRSTACTIVETIME.equals(attrName)) {
firstActiveTime = Long.valueOf(attrValue);
firstActiveTime = Long.parseLong(attrValue);
} else if (ATTR_LASTACTIVETIME.equals(attrName)) {
lastActiveTime = Long.valueOf(attrValue);
lastActiveTime = Long.parseLong(attrValue);
} else if (ATTR_LASTDESCRIPTION.equals(attrName)) {
lastDescription = attrValue;
} else if (ATTR_LASTTIMEMOVED.equals(attrName)) {
lastTimeOnTop = Long.valueOf(attrValue);
lastTimeOnTop = Long.parseLong(attrValue);
} else if (ATTR_NEVERRELINQUISH.equals(attrName)) {
neverRelinquishIdentity = Boolean.valueOf(attrValue);
neverRelinquishIdentity = Boolean.parseBoolean(attrValue);
} else if (attrName.startsWith(TaskThumbnailInfo.ATTR_TASK_THUMBNAILINFO_PREFIX)) {
thumbnailInfo.restoreFromXml(attrName, attrValue);
} else if (attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) {
@@ -1284,7 +1284,7 @@ final class TaskRecord {
resizeMode = (resizeMode == RESIZE_MODE_CROP_WINDOWS)
? RESIZE_MODE_FORCE_RESIZEABLE : resizeMode;
} else if (ATTR_PRIVILEGED.equals(attrName)) {
privileged = Boolean.valueOf(attrValue);
privileged = Boolean.parseBoolean(attrValue);
} else if (ATTR_NON_FULLSCREEN_BOUNDS.equals(attrName)) {
bounds = Rect.unflattenFromString(attrValue);
} else if (ATTR_MINIMAL_WIDTH.equals(attrName)) {

View File

@@ -593,7 +593,7 @@ public class JobStore {
if (XML_TAG_PERIODIC.equals(parser.getName())) {
try {
String val = parser.getAttributeValue(null, "period");
final long periodMillis = Long.valueOf(val);
final long periodMillis = Long.parseLong(val);
val = parser.getAttributeValue(null, "flex");
final long flexMillis = (val != null) ? Long.valueOf(val) : periodMillis;
jobBuilder.setPeriodic(periodMillis, flexMillis);
@@ -718,7 +718,7 @@ public class JobStore {
private void maybeBuildBackoffPolicyFromXml(JobInfo.Builder jobBuilder, XmlPullParser parser) {
String val = parser.getAttributeValue(null, "initial-backoff");
if (val != null) {
long initialBackoff = Long.valueOf(val);
long initialBackoff = Long.parseLong(val);
val = parser.getAttributeValue(null, "backoff-policy");
int backoffPolicy = Integer.parseInt(val); // Will throw NFE which we catch higher up.
jobBuilder.setBackoffCriteria(initialBackoff, backoffPolicy);
@@ -741,14 +741,14 @@ public class JobStore {
long latestRunTimeElapsed = JobStatus.NO_LATEST_RUNTIME;
String val = parser.getAttributeValue(null, "deadline");
if (val != null) {
long latestRuntimeWallclock = Long.valueOf(val);
long latestRuntimeWallclock = Long.parseLong(val);
long maxDelayElapsed =
Math.max(latestRuntimeWallclock - nowWallclock, 0);
latestRunTimeElapsed = nowElapsed + maxDelayElapsed;
}
val = parser.getAttributeValue(null, "delay");
if (val != null) {
long earliestRuntimeWallclock = Long.valueOf(val);
long earliestRuntimeWallclock = Long.parseLong(val);
long minDelayElapsed =
Math.max(earliestRuntimeWallclock - nowWallclock, 0);
earliestRunTimeElapsed = nowElapsed + minDelayElapsed;

View File

@@ -4099,7 +4099,7 @@ public class NotificationManagerService extends SystemService {
filter.stats = true;
if (ai < args.length-1) {
ai++;
filter.since = Long.valueOf(args[ai]);
filter.since = Long.parseLong(args[ai]);
} else {
filter.since = 0;
}

View File

@@ -134,11 +134,11 @@ public class MainActivity extends Activity {
String delay = mDelayEditText.getText().toString();
if (delay != null && !TextUtils.isEmpty(delay)) {
builder.setMinimumLatency(Long.valueOf(delay) * 1000);
builder.setMinimumLatency(Long.parseLong(delay) * 1000);
}
String deadline = mDeadlineEditText.getText().toString();
if (deadline != null && !TextUtils.isEmpty(deadline)) {
builder.setOverrideDeadline(Long.valueOf(deadline) * 1000);
builder.setOverrideDeadline(Long.parseLong(deadline) * 1000);
}
boolean requiresUnmetered = mWiFiConnectivityRadioButton.isChecked();
boolean requiresAnyConnectivity = mAnyConnectivityRadioButton.isChecked();

View File

@@ -214,7 +214,7 @@ public class TrackerService extends Service {
private long getLocationUpdateTime() {
try {
String timeString = getPreferences().getString(MIN_TIME_PREF, "0");
long secondsTime = Long.valueOf(timeString);
long secondsTime = Long.parseLong(timeString);
return secondsTime * 1000;
}
catch (NumberFormatException e) {