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:
Paul Keith
2019-02-17 05:20:04 +01:00
parent d6a273df74
commit c9f1d6744f
10 changed files with 13 additions and 15 deletions

View File

@@ -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]);
}
/**

View File

@@ -679,7 +679,7 @@ public final class LineageHardwareManager {
remapped.add(r);
}
}
return remapped.toArray(new DisplayMode[remapped.size()]);
return remapped.toArray(new DisplayMode[0]);
}
}

View File

@@ -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) {