Bug 1551407 - Improve readability of LoginAutoCompleteResult. r=sfoster
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Mon, 20 May 2019 18:21:34 +0000
changeset 474579 00df22944d9abc5b26009738e4cfc4070ff2ed66
parent 474578 586ea3b717009c60d461b56fe874a86332523b25
child 474580 c74ca2406a0d4c550c998a5e911d7262351b75eb
push id36042
push userdvarga@mozilla.com
push dateTue, 21 May 2019 04:19:40 +0000
treeherdermozilla-central@ca560ff55451 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfoster
bugs1551407
milestone69.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 1551407 - Improve readability of LoginAutoCompleteResult. r=sfoster Differential Revision: https://phabricator.services.mozilla.com/D31028
toolkit/components/passwordmgr/LoginAutoCompleteResult.jsm
--- a/toolkit/components/passwordmgr/LoginAutoCompleteResult.jsm
+++ b/toolkit/components/passwordmgr/LoginAutoCompleteResult.jsm
@@ -32,46 +32,50 @@ XPCOMUtils.defineLazyServiceGetter(this,
                                    Ci.nsIFormFillController);
 XPCOMUtils.defineLazyPreferenceGetter(this, "SHOULD_SHOW_ORIGIN",
                                       "signon.showAutoCompleteOrigins");
 
 XPCOMUtils.defineLazyGetter(this, "log", () => {
   return LoginHelper.createLogger("LoginAutoCompleteResult");
 });
 
+function loginSort(a, b) {
+  let userA = a.username.toLowerCase();
+  let userB = b.username.toLowerCase();
+
+  if (userA < userB) {
+    return -1;
+  }
+
+  if (userA > userB) {
+    return 1;
+  }
+
+  return 0;
+}
+
+function findDuplicates(loginList) {
+  let seen = new Set();
+  let duplicates = new Set();
+  for (let login of loginList) {
+    if (seen.has(login.username)) {
+      duplicates.add(login.username);
+    }
+    seen.add(login.username);
+  }
+  return duplicates;
+}
 
 // nsIAutoCompleteResult implementation
-function LoginAutoCompleteResult(aSearchString, matchingLogins, {isSecure, messageManager, isPasswordField, hostname}) {
-  function loginSort(a, b) {
-    let userA = a.username.toLowerCase();
-    let userB = b.username.toLowerCase();
-
-    if (userA < userB) {
-      return -1;
-    }
-
-    if (userA > userB) {
-      return 1;
-    }
-
-    return 0;
-  }
-
-  function findDuplicates(loginList) {
-    let seen = new Set();
-    let duplicates = new Set();
-    for (let login of loginList) {
-      if (seen.has(login.username)) {
-        duplicates.add(login.username);
-      }
-      seen.add(login.username);
-    }
-    return duplicates;
-  }
-
+function LoginAutoCompleteResult(aSearchString, matchingLogins, {
+  isSecure,
+  messageManager,
+  isPasswordField,
+  hostname,
+}) {
   let hidingFooterOnPWFieldAutoOpened = false;
   function isFooterEnabled() {
     // We need to check LoginHelper.enabled here since the insecure warning should
     // appear even if pwmgr is disabled but the footer should never appear in that case.
     if (!LoginHelper.showAutoCompleteFooter || !LoginHelper.enabled) {
       return false;
     }