AutofillService: Speed item loading

Don't make cacheable function calls in loops

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-02-21 21:54:43 +05:30
parent 9787489bc5
commit 812b92ab38

View file

@ -412,12 +412,12 @@ class AutofillService : AccessibilityService(), CoroutineScope by CoroutineScope
// populate the dialog items, always with pick + pick and match. Could // populate the dialog items, always with pick + pick and match. Could
// make it optional (or make height a setting for the same effect) // make it optional (or make height a setting for the same effect)
val itemNames = arrayOfNulls<CharSequence>(items.size + 2) val itemNames = arrayOfNulls<CharSequence>(items.size + 2)
val passwordDirectory = PasswordRepository.getRepositoryDirectory(applicationContext).toString()
val autofillFullPath = settings!!.getBoolean("autofill_full_path", false)
for (i in items.indices) { for (i in items.indices) {
if (settings!!.getBoolean("autofill_full_path", false)) { if (autofillFullPath) {
itemNames[i] = items[i].path.replace(".gpg", "") itemNames[i] = items[i].path.replace(".gpg", "")
.replace( .replace("$passwordDirectory/", "")
PasswordRepository.getRepositoryDirectory(applicationContext).toString() + "/",
"")
} else { } else {
itemNames[i] = items[i].name.replace(".gpg", "") itemNames[i] = items[i].name.replace(".gpg", "")
} }