Do not allocate space for arrays that do not need to be allocated

Those arrays are just there for the type system. Creating them with a big size
is not necessary and uses unnecessary resources.
This commit is contained in:
ByteHamster 2020-01-02 18:40:03 +01:00
parent 5fc6877a87
commit 7f402168b7
5 changed files with 5 additions and 7 deletions

View File

@ -201,7 +201,7 @@ public class UITestUtils {
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.setCompleteFeed(hostedFeeds.toArray(new Feed[hostedFeeds.size()]));
adapter.setCompleteFeed(hostedFeeds.toArray(new Feed[0]));
adapter.setQueue(queue);
adapter.close();
EventBus.getDefault().post(new FeedListUpdateEvent(hostedFeeds));

View File

@ -485,7 +485,7 @@ public class EpisodesApplyActionFragment extends Fragment {
}
}
try {
DownloadRequester.getInstance().downloadMedia(getActivity(), toDownload.toArray(new FeedItem[toDownload.size()]));
DownloadRequester.getInstance().downloadMedia(getActivity(), toDownload.toArray(new FeedItem[0]));
} catch (DownloadRequestException e) {
e.printStackTrace();
DownloadRequestErrorDialogCreator.newRequestErrorDialog(getActivity(), e.getMessage());

View File

@ -146,7 +146,7 @@ public class AllEpisodesFragment extends EpisodesListFragment {
FilterDialog filterDialog = new FilterDialog(getContext(), feedItemFilter) {
@Override
protected void updateFilter(Set<String> filterValues) {
feedItemFilter = new FeedItemFilter(filterValues.toArray(new String[filterValues.size()]));
feedItemFilter = new FeedItemFilter(filterValues.toArray(new String[0]));
loadItems();
}
};

View File

@ -131,9 +131,7 @@ public class AutoDownloadPreferencesFragment extends PreferenceFragmentCompat {
prefValuesList.add(key);
}
UserPreferences.setAutodownloadSelectedNetworks(
prefValuesList.toArray(new String[prefValuesList.size()])
);
UserPreferences.setAutodownloadSelectedNetworks(prefValuesList.toArray(new String[0]));
return true;
} else {
return false;

View File

@ -108,7 +108,7 @@ public class FeedMenuHandler {
FilterDialog filterDialog = new FilterDialog(context, selectedFeed.getItemFilter()) {
@Override
protected void updateFilter(Set<String> filterValues) {
selectedFeed.setItemFilter(filterValues.toArray(new String[filterValues.size()]));
selectedFeed.setItemFilter(filterValues.toArray(new String[0]));
DBWriter.setFeedItemsFilter(selectedFeed.getId(), filterValues);
}
};