Bug 1081375: Remove write-only datastructures. r=rnewman
authorChris Kitching <chriskitching@linux.com>
Fri, 10 Oct 2014 23:24:12 +0100
changeset 221097 0f90bdd80217801fb50ddccd5b9a243d356efcea
parent 221096 16fbd77efbdf8cc661714a4abb99459e96ce4a0d
child 221098 202a654f19c3953135802a964e4e4f55d28169a7
push id28010
push userkwierso@gmail.com
push dateWed, 24 Dec 2014 00:29:29 +0000
treeherdermozilla-central@8b881bea204a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1081375
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1081375: Remove write-only datastructures. r=rnewman
mobile/android/base/GeckoProfilesProvider.java
mobile/android/base/prompts/PromptListItem.java
mobile/android/base/sync/repositories/android/AndroidBrowserHistoryDataAccessor.java
mobile/android/base/sync/repositories/android/AndroidBrowserRepositoryDataAccessor.java
--- a/mobile/android/base/GeckoProfilesProvider.java
+++ b/mobile/android/base/GeckoProfilesProvider.java
@@ -65,23 +65,16 @@ public class GeckoProfilesProvider exten
         return values;
     }
 
     protected void addRowForProfile(final MatrixCursor cursor, final int len, final int nameIndex, final int pathIndex, final String name, final String path) {
         if (path == null || name == null) {
             return;
         }
 
-        String[] values = new String[len];
-        if (nameIndex >= 0) {
-            values[nameIndex] = name;
-        }
-        if (pathIndex >= 0) {
-            values[pathIndex] = path;
-        }
         cursor.addRow(profileValues(name, path, len, nameIndex, pathIndex));
     }
 
     protected Cursor getCursorForProfiles(final String[] args, Map<String, String> profiles) {
         // Compute the projection.
         int nameIndex = -1;
         int pathIndex = -1;
         for (int i = 0; i < args.length; ++i) {
--- a/mobile/android/base/prompts/PromptListItem.java
+++ b/mobile/android/base/prompts/PromptListItem.java
@@ -102,21 +102,19 @@ public class PromptListItem {
     }
 
     static PromptListItem[] getArray(JSONArray items) {
         if (items == null) {
             return new PromptListItem[0];
         }
 
         int length = items.length();
-        List<PromptListItem> list = new ArrayList<PromptListItem>(length);
+        List<PromptListItem> list = new ArrayList<>(length);
         for (int i = 0; i < length; i++) {
             try {
                 PromptListItem item = new PromptListItem(items.getJSONObject(i));
                 list.add(item);
             } catch(Exception ex) { }
         }
 
-        PromptListItem[] arrays = new PromptListItem[length];
-        list.toArray(arrays);
-        return arrays;
+        return list.toArray(new PromptListItem[length]);
     }
 }
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserHistoryDataAccessor.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserHistoryDataAccessor.java
@@ -117,26 +117,22 @@ public class AndroidBrowserHistoryDataAc
    */
   public int bulkInsert(ArrayList<HistoryRecord> records) throws NullCursorException {
     if (records.isEmpty()) {
       Logger.debug(LOG_TAG, "No records to insert, returning.");
     }
 
     int size = records.size();
     ContentValues[] cvs = new ContentValues[size];
-    String[] guids = new String[size];
-    Map<String, Record> guidToRecord = new HashMap<String, Record>();
     int index = 0;
     for (Record record : records) {
       if (record.guid == null) {
         throw new IllegalArgumentException("Record with null GUID passed in to bulkInsert.");
       }
       cvs[index] = getContentValues(record);
-      guids[index] = record.guid;
-      guidToRecord.put(record.guid, record);
       index += 1;
     }
 
     // First update the history records.
     int inserted = context.getContentResolver().bulkInsert(getUri(), cvs);
     if (inserted == size) {
       Logger.debug(LOG_TAG, "Inserted " + inserted + " records, as expected.");
     } else {
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserRepositoryDataAccessor.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserRepositoryDataAccessor.java
@@ -212,18 +212,16 @@ public abstract class AndroidBrowserRepo
 
     if (index != size) {
       // bulkInsert treats null ContentValues as blank rows, which we don't want
       // to insert into the database.
       // We expect exceptions in getContentValues to be exceedingly rare, so we
       // re-allocate in the (rare) error case and maintain a fast path for the
       // success case.
       size = index;
-      ContentValues[] temp = new ContentValues[size];
-      System.arraycopy(cvs, 0, temp, 0, size); // No java.util.Arrays.copyOf in older Android SDKs.
     }
 
     int inserted = context.getContentResolver().bulkInsert(getUri(), cvs);
     if (inserted == size) {
       Logger.debug(LOG_TAG, "Inserted " + inserted + " records, as expected.");
     } else {
       Logger.debug(LOG_TAG, "Inserted " +
                    inserted + " records but expected " +