Bug 1395173 - Part 1. Cache computed values in form handler instance instead of prototype. r=lchang
authorRay Lin <ralin@mozilla.com>
Thu, 31 Aug 2017 16:38:54 +0800
changeset 428210 7943bf751331ece384c998ae685c601edec740d0
parent 428209 00b9a3c8a7fdd36a904e9c84371ce5f551abac53
child 428211 0b89aba4df90b3c6242d527aaaa98e2843f44f92
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslchang
bugs1395173
milestone57.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 1395173 - Part 1. Cache computed values in form handler instance instead of prototype. r=lchang MozReview-Commit-ID: Dwz6EmJ4VmN
browser/extensions/formautofill/FormAutofillHandler.jsm
--- a/browser/extensions/formautofill/FormAutofillHandler.jsm
+++ b/browser/extensions/formautofill/FormAutofillHandler.jsm
@@ -49,16 +49,22 @@ function FormAutofillHandler(form) {
      * Similar to the `fieldDetails` above but contains credit card fields only.
      */
     fieldDetails: [],
     /**
      * String of the filled creditCard's guid.
      */
     filledRecordGUID: null,
   };
+
+  this._cacheValue = {
+    allFieldNames: null,
+    oneLineStreetAddress: null,
+    matchingSelectOption: null,
+  };
 }
 
 FormAutofillHandler.prototype = {
   /**
    * DOM Form element to which this object is attached.
    */
   form: null,
 
@@ -164,22 +170,16 @@ FormAutofillHandler.prototype = {
       return this.address.fieldDetails;
     }
     if (FormAutofillUtils.isCreditCardField(fieldDetail.fieldName)) {
       return this.creditCard.fieldDetails;
     }
     return [];
   },
 
-  _cacheValue: {
-    allFieldNames: null,
-    oneLineStreetAddress: null,
-    matchingSelectOption: null,
-  },
-
   get allFieldNames() {
     if (!this._cacheValue.allFieldNames) {
       this._cacheValue.allFieldNames = this.fieldDetails.map(record => record.fieldName);
     }
     return this._cacheValue.allFieldNames;
   },
 
   _getOneLineStreetAddress(address) {