Don't create local vars when returning straight away

This commit is contained in:
addshore 2017-05-13 13:01:05 +02:00
parent 85182e3fb7
commit f019aa2865
4 changed files with 6 additions and 12 deletions

View file

@ -69,9 +69,8 @@ public class LicenseList {
int nameId = stringIdByName(stringId); int nameId = stringIdByName(stringId);
//Log.d("Commons", "LicenseList.nameForTemplate: nameId: " + nameId); //Log.d("Commons", "LicenseList.nameForTemplate: nameId: " + nameId);
if(nameId != 0) { if(nameId != 0) {
String name = res.getString(nameId);
//Log.d("Commons", "LicenseList.nameForTemplate: name: " + name); //Log.d("Commons", "LicenseList.nameForTemplate: name: " + name);
return name; return res.getString(nameId);
} }
return template; return template;
} }

View file

@ -357,8 +357,7 @@ public class CategorizationFragment extends Fragment {
new String[] {name}, new String[] {name},
null); null);
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
Category cat = Category.fromCursor(cursor); return Category.fromCursor(cursor);
return cat;
} }
} catch (RemoteException e) { } catch (RemoteException e) {
// This feels lazy, but to hell with checked exceptions. :) // This feels lazy, but to hell with checked exceptions. :)

View file

@ -108,7 +108,6 @@ public class MethodAUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
} }
Timber.d("Found categories from Method A search, waiting for filter"); Timber.d("Found categories from Method A search, waiting for filter");
ArrayList<String> filteredItems = new ArrayList<>(filterYears(categories)); return new ArrayList<>(filterYears(categories));
return filteredItems;
} }
} }

View file

@ -83,16 +83,14 @@ public class PrefixUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
if(TextUtils.isEmpty(filter)) { if(TextUtils.isEmpty(filter)) {
ArrayList<String> mergedItems = new ArrayList<>(catFragment.mergeItems()); ArrayList<String> mergedItems = new ArrayList<>(catFragment.mergeItems());
Timber.d("Merged items, waiting for filter"); Timber.d("Merged items, waiting for filter");
ArrayList<String> filteredItems = new ArrayList<>(filterYears(mergedItems)); return new ArrayList<>(filterYears(mergedItems));
return filteredItems;
} }
//if user types in something that is in cache, return cached category //if user types in something that is in cache, return cached category
if(catFragment.categoriesCache.containsKey(filter)) { if(catFragment.categoriesCache.containsKey(filter)) {
ArrayList<String> cachedItems = new ArrayList<>(catFragment.categoriesCache.get(filter)); ArrayList<String> cachedItems = new ArrayList<>(catFragment.categoriesCache.get(filter));
Timber.d("Found cache items, waiting for filter"); Timber.d("Found cache items, waiting for filter");
ArrayList<String> filteredItems = new ArrayList<>(filterYears(cachedItems)); return new ArrayList<>(filterYears(cachedItems));
return filteredItems;
} }
//otherwise if user has typed something in that isn't in cache, search API for matching categories //otherwise if user has typed something in that isn't in cache, search API for matching categories
@ -119,7 +117,6 @@ public class PrefixUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
} }
Timber.d("Found categories from Prefix search, waiting for filter"); Timber.d("Found categories from Prefix search, waiting for filter");
ArrayList<String> filteredItems = new ArrayList<>(filterYears(categories)); return new ArrayList<>(filterYears(categories));
return filteredItems;
} }
} }