sdk: Cleanup usage of List.toArray(T[] a)
* The parameter here only has to have the type you want it to return, so creating an array of size > 0 is unnecessary and wasteful Change-Id: I28e490fb6fa3703d7edca21b29d640105072947b
This commit is contained in:
@@ -54,7 +54,7 @@ public class AdbCommand extends Command {
|
||||
List<String> commandList = new ArrayList<String>(
|
||||
baseCommand.length + 1);
|
||||
commandList.addAll(Arrays.asList(baseCommand));
|
||||
String[] commands = commandList.toArray(new String[commandList.size()]);
|
||||
String[] commands = commandList.toArray(new String[0]);
|
||||
|
||||
if (MigrationTest.DEBUG) {
|
||||
System.out.println("Using commands: " + Arrays.toString(commands));
|
||||
|
||||
@@ -59,7 +59,7 @@ public class InsertCommand extends Command {
|
||||
commandList.add("--bind name:" + setting.getKeyType() + ":" + setting.getKey());
|
||||
commandList.add("--bind value:" + setting.getValueType() + ":"
|
||||
+ "\"" + setting.getValue() + "\"");
|
||||
commands = commandList.toArray(new String[commandList.size()]);
|
||||
commands = commandList.toArray(new String[0]);
|
||||
if (MigrationTest.DEBUG) {
|
||||
System.out.println("Using commands: " + Arrays.toString(commands));
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class QueryCommand extends Command {
|
||||
commandList.add(PROJECTION);
|
||||
commandList.add("--show-type"); //this is totally awesomely lineage specific
|
||||
commandList.add("true");
|
||||
commands = commandList.toArray(new String[commandList.size()]);
|
||||
commands = commandList.toArray(new String[0]);
|
||||
if (MigrationTest.DEBUG) {
|
||||
System.out.println("Using commands: " + Arrays.toString(commands));
|
||||
}
|
||||
|
||||
@@ -375,10 +375,9 @@ public class LineageWeatherManagerService extends LineageSystemService {
|
||||
contentValuesList.add(contentValues);
|
||||
}
|
||||
|
||||
ContentValues[] updateValues = new ContentValues[contentValuesList.size()];
|
||||
if (size != getContext().getContentResolver().bulkInsert(
|
||||
WeatherColumns.CURRENT_AND_FORECAST_WEATHER_URI,
|
||||
contentValuesList.toArray(updateValues))) {
|
||||
contentValuesList.toArray(new ContentValues[0]))) {
|
||||
Slog.w(TAG, "Failed to update the weather content provider");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -378,8 +378,7 @@ public class PerformanceManagerService extends LineageSystemService {
|
||||
@Override
|
||||
public PerformanceProfile[] getPowerProfiles() throws RemoteException {
|
||||
synchronized (mLock) {
|
||||
return mProfiles.values().toArray(
|
||||
new PerformanceProfile[mProfiles.size()]);
|
||||
return mProfiles.values().toArray(new PerformanceProfile[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@ public class ProfileManagerService extends LineageSystemService {
|
||||
|
||||
@Override
|
||||
public Profile[] getProfiles() {
|
||||
Profile[] profiles = getProfileList().toArray(new Profile[mProfiles.size()]);
|
||||
Profile[] profiles = getProfileList().toArray(new Profile[0]);
|
||||
Arrays.sort(profiles);
|
||||
return profiles;
|
||||
}
|
||||
@@ -492,7 +492,7 @@ public class ProfileManagerService extends LineageSystemService {
|
||||
|
||||
@Override
|
||||
public NotificationGroup[] getNotificationGroups() {
|
||||
return mGroups.values().toArray(new NotificationGroup[mGroups.size()]);
|
||||
return mGroups.values().toArray(new NotificationGroup[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -136,7 +136,7 @@ public class DisplayHardwareController extends LiveDisplayFeature {
|
||||
return;
|
||||
}
|
||||
|
||||
registerSettings(settings.toArray(new Uri[settings.size()]));
|
||||
registerSettings(settings.toArray(new Uri[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -507,7 +507,7 @@ public final class Profile implements Parcelable, Comparable {
|
||||
* @hide
|
||||
*/
|
||||
public ProfileGroup[] getProfileGroups() {
|
||||
return profileGroups.values().toArray(new ProfileGroup[profileGroups.size()]);
|
||||
return profileGroups.values().toArray(new ProfileGroup[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -566,7 +566,7 @@ public final class Profile implements Parcelable, Comparable {
|
||||
uuids.add(new ParcelUuid(u));
|
||||
}
|
||||
dest.writeInt(1);
|
||||
dest.writeParcelableArray(uuids.toArray(new Parcelable[uuids.size()]), flags);
|
||||
dest.writeParcelableArray(uuids.toArray(new Parcelable[0]), flags);
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
@@ -766,7 +766,7 @@ public final class Profile implements Parcelable, Comparable {
|
||||
* @return the secondary uuids for the Profile
|
||||
*/
|
||||
public UUID[] getSecondaryUuids() {
|
||||
return mSecondaryUuids.toArray(new UUID[mSecondaryUuids.size()]);
|
||||
return mSecondaryUuids.toArray(new UUID[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -679,7 +679,7 @@ public final class LineageHardwareManager {
|
||||
remapped.add(r);
|
||||
}
|
||||
}
|
||||
return remapped.toArray(new DisplayMode[remapped.size()]);
|
||||
return remapped.toArray(new DisplayMode[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -567,7 +567,7 @@ public final class Palette {
|
||||
scaledBitmap.getPixels(pixels, 0, width, 0, 0, width, height);
|
||||
|
||||
final ColorCutQuantizer quantizer = new ColorCutQuantizer(pixels, mMaxColors,
|
||||
mFilters.isEmpty() ? null : mFilters.toArray(new Filter[mFilters.size()]));
|
||||
mFilters.isEmpty() ? null : mFilters.toArray(new Filter[0]));
|
||||
|
||||
// If created a new bitmap, recycle it
|
||||
if (scaledBitmap != mBitmap) {
|
||||
|
||||
Reference in New Issue
Block a user