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/import/ImportBuffer.mc | |
| 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/import/ImportBuffer.mc')
| -rw-r--r-- | source/import/ImportBuffer.mc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/source/import/ImportBuffer.mc b/source/import/ImportBuffer.mc index 0aca548..dee0012 100644 --- a/source/import/ImportBuffer.mc +++ b/source/import/ImportBuffer.mc @@ -54,17 +54,15 @@ module ImportBuffer { return text; } - // Save text as the waiting import. Returns false (and saves nothing) - // when it is over MAX_TEXT_BYTES. - function save(store as Persist.Backend, keys as SealedBox.Keys, text as String, now as Long) as Boolean { - var plain = Bytes.fromUtf8(text); + // Save the text's UTF-8 bytes as the waiting import. Returns false (and + // saves nothing) when they are over MAX_TEXT_BYTES. The caller's bytes + // are left as they are. + function save(store as Persist.Backend, keys as SealedBox.Keys, plain as ByteArray, now as Long) as Boolean { if (plain.size() > MAX_TEXT_BYTES) { - Bytes.wipe(plain); return false; } clear(store); var box = SealedBox.seal(keys, Bytes.fromUtf8(AAD), plain); - Bytes.wipe(plain); var n = 0; for (var at = 0; at < box.size(); at += CHUNK_BYTES) { store.setValue(META_KEY + "." + n, box.slice(at, at + CHUNK_BYTES < box.size() ? at + CHUNK_BYTES : box.size())); |
