From 7f402168b7d51999dfe73058115e6184ee1ffb90 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Thu, 2 Jan 2020 18:40:03 +0100 Subject: [PATCH] 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. --- .../androidTest/java/de/test/antennapod/ui/UITestUtils.java | 2 +- .../danoeh/antennapod/dialog/EpisodesApplyActionFragment.java | 2 +- .../de/danoeh/antennapod/fragment/AllEpisodesFragment.java | 2 +- .../fragment/preferences/AutoDownloadPreferencesFragment.java | 4 +--- .../de/danoeh/antennapod/menuhandler/FeedMenuHandler.java | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java index 8e16d1a3b..936337cbf 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/UITestUtils.java @@ -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)); diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java index ff131aeba..100e33e0f 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java @@ -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()); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java index 3949a03a9..8df2c3819 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -146,7 +146,7 @@ public class AllEpisodesFragment extends EpisodesListFragment { FilterDialog filterDialog = new FilterDialog(getContext(), feedItemFilter) { @Override protected void updateFilter(Set filterValues) { - feedItemFilter = new FeedItemFilter(filterValues.toArray(new String[filterValues.size()])); + feedItemFilter = new FeedItemFilter(filterValues.toArray(new String[0])); loadItems(); } }; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AutoDownloadPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AutoDownloadPreferencesFragment.java index fa17fed0a..469697e23 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AutoDownloadPreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AutoDownloadPreferencesFragment.java @@ -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; diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java index e32deba27..44b6453e5 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java @@ -108,7 +108,7 @@ public class FeedMenuHandler { FilterDialog filterDialog = new FilterDialog(context, selectedFeed.getItemFilter()) { @Override protected void updateFilter(Set filterValues) { - selectedFeed.setItemFilter(filterValues.toArray(new String[filterValues.size()])); + selectedFeed.setItemFilter(filterValues.toArray(new String[0])); DBWriter.setFeedItemsFilter(selectedFeed.getId(), filterValues); } };