diff options
| author | cirakg <cirakg@cirakg.xyz> | 2026-10-21 03:55:01 +0200 |
|---|---|---|
| committer | cirakg <cirakg@cirakg.xyz> | 2026-10-21 03:55:01 +0200 |
| commit | a69e23fb5266dd942d125239e7dcbe8a7c8ab956 (patch) | |
| tree | 164c7ed21b550ac3d5fef567060ffad4e40e4583 /source/settings | |
| parent | 6039571d70b1f6de1ae384e58e11879869be356c (diff) | |
perf(import): keep parsed items packed and the pasted text once
A parsed import item with its Entry took about 760 bytes as objects on the
Forerunner 255S; packed into one Codec ByteArray it takes about 110, and
the importer unpacks one item per store step (wiping the packed secret).
Aegis group names are resolved when unpacking, so no step repacks all
items. The JSON is parsed from the untrimmed text's bytes and the string
is dropped; an incomplete part is saved from those bytes. The form hash
is computed before the importer copies the text.
The peak of a 100-entry import on the 255S falls from 56 % to 45 %.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'source/settings')
| -rw-r--r-- | source/settings/SettingsJob.mc | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/source/settings/SettingsJob.mc b/source/settings/SettingsJob.mc index e6e7bcf..2fc4a3d 100644 --- a/source/settings/SettingsJob.mc +++ b/source/settings/SettingsJob.mc @@ -105,24 +105,31 @@ class SettingsJob extends Jobs.Job { endImport(["Import: waiting import cancelled."] as Array<String>, "Waiting import cancelled", false); return; } - var content = new Forms.Content("import"); - content.add(importMode); - content.add(locked); - var text = ""; - for (var i = 1; i <= IMPORT_TEXT_FIELDS; i++) { - var part = Forms.rawText(_store, "impText" + i); - content.add(part); - text += part; - } - _hash = Forms.hash(_vault, content); + _hash = importHash(importMode, locked); if (Forms.alreadyApplied(_vault, _hash)) { endImport(["Import: already applied. Change the text to import again."] as Array<String>, "Already imported", true); return; } + var text = ""; + for (var i = 1; i <= IMPORT_TEXT_FIELDS; i++) { + text += Forms.rawText(_store, "impText" + i); + } _importStart = System.getTimer(); _importer = new Importer(_vault, text, importMode, locked, _now); } + // The import form's hash. Its own function, so the field bytes it hashes + // are freed before the importer makes its copy of the text. + private function importHash(importMode as Number, locked as Boolean) as String { + var content = new Forms.Content("import"); + content.add(importMode); + content.add(locked); + for (var i = 1; i <= IMPORT_TEXT_FIELDS; i++) { + content.add(Forms.rawText(_store, "impText" + i)); + } + return Forms.hash(_vault, content); + } + private function finishImport(importer as Importer) as Void { _importer = null; var report = importer.report; |
