From c70b0605380dbf4aa0c75eaedf5ce319d6febd4d Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Mon, 22 Aug 2011 10:38:28 -0700 Subject: [PATCH] Bug 637576 - Part 1: Sync Form engine: reuse column name arrays. r=philikon --- services/sync/modules/engines/forms.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/sync/modules/engines/forms.js b/services/sync/modules/engines/forms.js index b3840d28edf..21ae43c557f 100644 --- a/services/sync/modules/engines/forms.js +++ b/services/sync/modules/engines/forms.js @@ -65,6 +65,9 @@ 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( @@ -73,14 +76,14 @@ let FormWrapper = { "((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) { @@ -92,7 +95,7 @@ let FormWrapper = { 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... @@ -124,7 +127,7 @@ let FormWrapper = { 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) {