Bug 868952 - Fix the getAll(...) function in AlarmDB to be more efficient. r=clian
authorZachary Easterbrook <FishLikeHexagon@gmail.com>
Mon, 20 May 2013 07:47:38 -0400
changeset 139491 3e60740c1a32c3dbb4ba556faf816e6d07511cb8
parent 139490 a9547c16624f0df61ed89c1e656184b4a413c059
child 139492 81c7af2e48d9081ab5b67e9d87c77ca936601013
push id3911
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 20:17:26 +0000
treeherdermozilla-aurora@7e26ca8db92b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersclian
bugs868952
milestone24.0a1
Bug 868952 - Fix the getAll(...) function in AlarmDB to be more efficient. r=clian
dom/alarm/AlarmDB.jsm
--- a/dom/alarm/AlarmDB.jsm
+++ b/dom/alarm/AlarmDB.jsm
@@ -134,25 +134,23 @@ AlarmDB.prototype = {
    */
   getAll: function getAll(aManifestURL, aSuccessCb, aErrorCb) {
     debug("getAll()");
 
     this.newTxn(
       "readonly",
       ALARMSTORE_NAME,
       function txnCb(aTxn, aStore) {
-        if (!aTxn.result)
+        if (!aTxn.result) {
           aTxn.result = [];
+        }
 
-        aStore.mozGetAll().onsuccess = function setTxnResult(aEvent) {
-          aEvent.target.result.forEach(function addAlarm(aAlarm) {
-            if (!aManifestURL || aManifestURL == aAlarm.manifestURL)
-              aTxn.result.push(aAlarm);
-          });
-
+        let index = aStore.index("manifestURL");
+        index.mozGetAll(aManifestURL).onsuccess = function setTxnResult(aEvent) {
+          aTxn.result = aEvent.target.result;
           debug("Request successful. Record count: " + aTxn.result.length);
         };
       },
       aSuccessCb,
       aErrorCb
     );
   }
 };