Browse Source

Spotbugs: precize allocation of a collection

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 năm trước cách đây
mục cha
commit
7a4785e083

+ 1 - 1
app/src/main/java/com/nextcloud/talk/components/filebrowser/webdav/DavUtils.java

@@ -74,7 +74,7 @@ public class DavUtils {
     public static final String PROPERTY_QUOTA_AVAILABLE_BYTES = "quota-available-bytes";
 
     static Property.Name[] getAllPropSet() {
-        List<Property.Name> props = new ArrayList<>();
+        List<Property.Name> props = new ArrayList<>(20);
 
         props.add(DisplayName.NAME);
         props.add(GetContentType.NAME);

+ 1 - 1
app/src/main/java/com/nextcloud/talk/components/filebrowser/webdav/ReadFilesystemOperation.java

@@ -69,7 +69,6 @@ public class ReadFilesystemOperation {
         DavResponse davResponse = new DavResponse();
         final List<Response> memberElements = new ArrayList<>();
         final Response[] rootElement = new Response[1];
-        final List<BrowserFile> remoteFiles = new ArrayList<>();
 
         try {
             new DavResource(okHttpClient, HttpUrl.parse(url)).propfind(depth, DavUtils.getAllPropSet(),
@@ -94,6 +93,7 @@ public class ReadFilesystemOperation {
             Log.w(TAG, "Error reading remote path");
         }
 
+        final List<BrowserFile> remoteFiles = new ArrayList<>(1 + memberElements.size());
         remoteFiles.add(BrowserFile.Companion.getModelFromResponse(rootElement[0],
                 rootElement[0].getHref().toString().substring(basePath.length())));
         for (Response memberElement : memberElements) {

+ 2 - 1
app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java

@@ -147,7 +147,8 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
                         if (mentionsList.size() == 0) {
                             adapter.clear();
                         } else {
-                            List<AbstractFlexibleItem> internalAbstractFlexibleItemList = new ArrayList<>();
+                            List<AbstractFlexibleItem> internalAbstractFlexibleItemList =
+                                new ArrayList<>(mentionsList.size());
                             for (Mention mention : mentionsList) {
                                 internalAbstractFlexibleItemList.add(
                                         new MentionAutocompleteItem(