{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments/52687681","id":52687681,"diff_hunk":"@@ -400,73 +418,91 @@ private class LoginCursorDataSource: NSObject, UITableViewDataSource {\n     }\n \n     @objc func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n-        return loginsForSection(section).count\n+        return loginsForSection(section)?.count ?? 0\n     }\n \n     @objc func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {\n         let cell = tableView.dequeueReusableCellWithIdentifier(LoginCellIdentifier, forIndexPath: indexPath) as! LoginTableViewCell\n-\n-        let login = loginAtIndexPath(indexPath)\n+        let login = loginAtIndexPath(indexPath)!\n         cell.style = .NoIconAndBothLabels\n         cell.updateCellWithLogin(login)\n-\n         return cell\n     }\n \n     @objc func sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? {\n-        return sectionIndexTitles()\n+        return titles.map { String($0) }\n     }\n \n     @objc func tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int {\n-        guard let titles = sectionIndexTitles() where index < titles.count && index >= 0 else {\n-            return 0\n-        }\n-        return titles.indexOf(title) ?? 0\n+        return titles.indexOf(Character(title)) ?? 0\n     }\n \n     @objc func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {\n-        return sectionIndexTitles()?[section]\n+        return String(titles[section])\n     }\n \n-    private func sectionIndexTitles() -> [String]? {\n-        guard cursor?.count > 0 else {\n-            return nil\n+    private func computeLoginSections() {\n+        titles.removeAll()\n+        sections.removeAll()\n+\n+        guard allLogins.count > 0 else {\n+            return\n+        }\n+\n+        // Precompute the baseDomain, host, and hostname values for sorting later on. At the moment\n+        // baseDomain() is a costly call because of the ETLD lookup tables.\n+        var domainLookup = [GUID: (String?, String?, String)]()","path":"Client/Frontend/Login Management/LoginListViewController.swift","position":134,"original_position":134,"commit_id":"7cfba1794d2a3a6db18438ad4277facb4267b79b","original_commit_id":"7cfba1794d2a3a6db18438ad4277facb4267b79b","user":{"login":"thebnich","id":1093266,"avatar_url":"https://avatars.githubusercontent.com/u/1093266?v=3","gravatar_id":"","url":"https://api.github.com/users/thebnich","html_url":"https://github.com/thebnich","followers_url":"https://api.github.com/users/thebnich/followers","following_url":"https://api.github.com/users/thebnich/following{/other_user}","gists_url":"https://api.github.com/users/thebnich/gists{/gist_id}","starred_url":"https://api.github.com/users/thebnich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thebnich/subscriptions","organizations_url":"https://api.github.com/users/thebnich/orgs","repos_url":"https://api.github.com/users/thebnich/repos","events_url":"https://api.github.com/users/thebnich/events{/privacy}","received_events_url":"https://api.github.com/users/thebnich/received_events","type":"User","site_admin":false},"body":"Maybe use named tuples here so that the code below is a bit more readable -- the magic numbers (i.e., `domainsA.2 < domainsB.2`) aren't very clear.","created_at":"2016-02-11T23:54:24Z","updated_at":"2016-02-11T23:54:24Z","html_url":"https://github.com/mozilla/firefox-ios/pull/1525#discussion_r52687681","pull_request_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1525","_links":{"self":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments/52687681"},"html":{"href":"https://github.com/mozilla/firefox-ios/pull/1525#discussion_r52687681"},"pull_request":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1525"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1525","id":59078902,"html_url":"https://github.com/mozilla/firefox-ios/pull/1525","diff_url":"https://github.com/mozilla/firefox-ios/pull/1525.diff","patch_url":"https://github.com/mozilla/firefox-ios/pull/1525.patch","issue_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/1525","number":1525,"state":"open","locked":false,"title":"Bug 1243156 - Added caching for section/title calculations for the login list","user":{"login":"sleroux","id":434322,"avatar_url":"https://avatars.githubusercontent.com/u/434322?v=3","gravatar_id":"","url":"https://api.github.com/users/sleroux","html_url":"https://github.com/sleroux","followers_url":"https://api.github.com/users/sleroux/followers","following_url":"https://api.github.com/users/sleroux/following{/other_user}","gists_url":"https://api.github.com/users/sleroux/gists{/gist_id}","starred_url":"https://api.github.com/users/sleroux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleroux/subscriptions","organizations_url":"https://api.github.com/users/sleroux/orgs","repos_url":"https://api.github.com/users/sleroux/repos","events_url":"https://api.github.com/users/sleroux/events{/privacy}","received_events_url":"https://api.github.com/users/sleroux/received_events","type":"User","site_admin":false},"body":"For testing, I generated ~200 logins and scrolled and everything seemed to be buttery smooth. The sluggish scrolling was being caused by regenerating the section data when cells were recycled along with the expensive publicSuffixFromHost method called from baseDomain(). Now, when logins are assigned to the data source the sections are computed once and cached. I also sprinkled a few minor clean ups such as changing LoginDataSource's cursor to an array and added some subscript methods.","created_at":"2016-02-11T19:14:33Z","updated_at":"2016-02-11T23:54:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1d164cd0823785d61cebb01d805af73fa753c47a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1525/commits","review_comments_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1525/comments","review_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/1525/comments","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/7cfba1794d2a3a6db18438ad4277facb4267b79b","head":{"label":"mozilla:sleroux/Bug1243156-ListJank","ref":"sleroux/Bug1243156-ListJank","sha":"7cfba1794d2a3a6db18438ad4277facb4267b79b","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":26133979,"name":"firefox-ios","full_name":"mozilla/firefox-ios","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/firefox-ios","description":"Firefox for iOS","fork":false,"url":"https://api.github.com/repos/mozilla/firefox-ios","forks_url":"https://api.github.com/repos/mozilla/firefox-ios/forks","keys_url":"https://api.github.com/repos/mozilla/firefox-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/firefox-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/firefox-ios/teams","hooks_url":"https://api.github.com/repos/mozilla/firefox-ios/hooks","issue_events_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/firefox-ios/events","assignees_url":"https://api.github.com/repos/mozilla/firefox-ios/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/firefox-ios/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/firefox-ios/tags","blobs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/firefox-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/firefox-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/firefox-ios/languages","stargazers_url":"https://api.github.com/repos/mozilla/firefox-ios/stargazers","contributors_url":"https://api.github.com/repos/mozilla/firefox-ios/contributors","subscribers_url":"https://api.github.com/repos/mozilla/firefox-ios/subscribers","subscription_url":"https://api.github.com/repos/mozilla/firefox-ios/subscription","commits_url":"https://api.github.com/repos/mozilla/firefox-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/firefox-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/firefox-ios/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/firefox-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/firefox-ios/merges","archive_url":"https://api.github.com/repos/mozilla/firefox-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/firefox-ios/downloads","issues_url":"https://api.github.com/repos/mozilla/firefox-ios/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/firefox-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/firefox-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/firefox-ios/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/firefox-ios/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/firefox-ios/deployments","created_at":"2014-11-03T19:07:02Z","updated_at":"2016-02-11T15:55:40Z","pushed_at":"2016-02-11T22:34:28Z","git_url":"git://github.com/mozilla/firefox-ios.git","ssh_url":"git@github.com:mozilla/firefox-ios.git","clone_url":"https://github.com/mozilla/firefox-ios.git","svn_url":"https://github.com/mozilla/firefox-ios","homepage":"","size":118498,"stargazers_count":5280,"watchers_count":5280,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":977,"mirror_url":null,"open_issues_count":78,"forks":977,"open_issues":78,"watchers":5280,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"9eb408444bf0009759dfbecc1ac2ec9d9888e8b9","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":26133979,"name":"firefox-ios","full_name":"mozilla/firefox-ios","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/firefox-ios","description":"Firefox for iOS","fork":false,"url":"https://api.github.com/repos/mozilla/firefox-ios","forks_url":"https://api.github.com/repos/mozilla/firefox-ios/forks","keys_url":"https://api.github.com/repos/mozilla/firefox-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/firefox-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/firefox-ios/teams","hooks_url":"https://api.github.com/repos/mozilla/firefox-ios/hooks","issue_events_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/firefox-ios/events","assignees_url":"https://api.github.com/repos/mozilla/firefox-ios/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/firefox-ios/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/firefox-ios/tags","blobs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/firefox-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/firefox-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/firefox-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/firefox-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/firefox-ios/languages","stargazers_url":"https://api.github.com/repos/mozilla/firefox-ios/stargazers","contributors_url":"https://api.github.com/repos/mozilla/firefox-ios/contributors","subscribers_url":"https://api.github.com/repos/mozilla/firefox-ios/subscribers","subscription_url":"https://api.github.com/repos/mozilla/firefox-ios/subscription","commits_url":"https://api.github.com/repos/mozilla/firefox-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/firefox-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/firefox-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/firefox-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/firefox-ios/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/firefox-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/firefox-ios/merges","archive_url":"https://api.github.com/repos/mozilla/firefox-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/firefox-ios/downloads","issues_url":"https://api.github.com/repos/mozilla/firefox-ios/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/firefox-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/firefox-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/firefox-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/firefox-ios/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/firefox-ios/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/firefox-ios/deployments","created_at":"2014-11-03T19:07:02Z","updated_at":"2016-02-11T15:55:40Z","pushed_at":"2016-02-11T22:34:28Z","git_url":"git://github.com/mozilla/firefox-ios.git","ssh_url":"git@github.com:mozilla/firefox-ios.git","clone_url":"https://github.com/mozilla/firefox-ios.git","svn_url":"https://github.com/mozilla/firefox-ios","homepage":"","size":118498,"stargazers_count":5280,"watchers_count":5280,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":977,"mirror_url":null,"open_issues_count":78,"forks":977,"open_issues":78,"watchers":5280,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1525"},"html":{"href":"https://github.com/mozilla/firefox-ios/pull/1525"},"issue":{"href":"https://api.github.com/repos/mozilla/firefox-ios/issues/1525"},"comments":{"href":"https://api.github.com/repos/mozilla/firefox-ios/issues/1525/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1525/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/firefox-ios/pulls/1525/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/firefox-ios/statuses/7cfba1794d2a3a6db18438ad4277facb4267b79b"}}}}