Bug 637576 - Part 1: Sync Form engine: reuse column name arrays. r=philikon
authorRichard Newman <rnewman@mozilla.com>
Mon, 22 Aug 2011 10:38:28 -0700
changeset 77045 0b209890603fab79662900a3ea24c7b2f4a9b227
parent 77044 7df9d5dfdb75c4c9b9aeab0c473cc0a55b24e741
child 77046 904783c227c86a82f1d92a556f61bdcbf7b45d38
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilikon
bugs637576
milestone9.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 637576 - Part 1: Sync Form engine: reuse column name arrays. r=philikon
services/sync/modules/engines/forms.js
--- a/services/sync/modules/engines/forms.js
+++ b/services/sync/modules/engines/forms.js
@@ -60,44 +60,47 @@ FormRec.prototype = {
 };
 
 Utils.deferGetSet(FormRec, "cleartext", ["name", "value"]);
 
 
 let FormWrapper = {
   _log: Log4Moz.repository.getLogger("Sync.Engine.Forms"),
 
+  _getEntryCols: ["name", "value"],
+  _guidCols:     ["guid"],
+
   getAllEntries: function getAllEntries() {
     // Sort by (lastUsed - minLast) / (maxLast - minLast) * timesUsed / maxTimes
     let query = Svc.Form.DBConnection.createAsyncStatement(
       "SELECT fieldname name, value FROM moz_formhistory " +
       "ORDER BY 1.0 * (lastUsed - (SELECT lastUsed FROM moz_formhistory ORDER BY lastUsed ASC LIMIT 1)) / " +
         "((SELECT lastUsed FROM moz_formhistory ORDER BY lastUsed DESC LIMIT 1) - (SELECT lastUsed FROM moz_formhistory ORDER BY lastUsed ASC LIMIT 1)) * " +
         "timesUsed / (SELECT timesUsed FROM moz_formhistory ORDER BY timesUsed DESC LIMIT 1) DESC " +
       "LIMIT 500");
-    return Async.querySpinningly(query, ["name", "value"]);
+    return Async.querySpinningly(query, this._getEntryCols);
   },
 
   getEntry: function getEntry(guid) {
     let query = Svc.Form.DBConnection.createAsyncStatement(
       "SELECT fieldname name, value FROM moz_formhistory WHERE guid = :guid");
     query.params.guid = guid;
-    return Async.querySpinningly(query, ["name", "value"])[0];
+    return Async.querySpinningly(query, this._getEntryCols)[0];
   },
 
   getGUID: function getGUID(name, value) {
     // Query for the provided entry.
     let getQuery = Svc.Form.DBConnection.createAsyncStatement(
       "SELECT guid FROM moz_formhistory " +
       "WHERE fieldname = :name AND value = :value");
     getQuery.params.name = name;
     getQuery.params.value = value;
 
     // Give the GUID if we found one.
-    let item = Async.querySpinningly(getQuery, ["guid"])[0];
+    let item = Async.querySpinningly(getQuery, this._guidCols)[0];
 
     if (!item) {
       // Shouldn't happen, but Bug 597400...
       // Might as well just return.
       this._log.warn("GUID query returned " + item + "; turn on Trace logging for details.");
       this._log.trace("getGUID(" + JSON.stringify(name) + ", " +
                       JSON.stringify(value) + ") => " + item);
       return null;
@@ -119,17 +122,17 @@ let FormWrapper = {
 
     return guid;
   },
 
   hasGUID: function hasGUID(guid) {
     let query = Svc.Form.DBConnection.createAsyncStatement(
       "SELECT guid FROM moz_formhistory WHERE guid = :guid LIMIT 1");
     query.params.guid = guid;
-    return Async.querySpinningly(query, ["guid"]).length == 1;
+    return Async.querySpinningly(query, this._guidCols).length == 1;
   },
 
   replaceGUID: function replaceGUID(oldGUID, newGUID) {
     let query = Svc.Form.DBConnection.createAsyncStatement(
       "UPDATE moz_formhistory SET guid = :newGUID WHERE guid = :oldGUID");
     query.params.oldGUID = oldGUID;
     query.params.newGUID = newGUID;
     Async.querySpinningly(query);