review(mail/richtext): below-cut perf & correctness nits #298

Closed
opened 2026-07-04 06:46:43 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-04 06:46:43 +00:00 (Migrated from github.com)

Phase-3 review — below-the-cut findings (Backlog, for review):

  • Regex recompilation (HtmlToText.kt:23-31): 4 Regex(...) literals built per convert() call (hot path: once per fetched body during sync). Hoist to private val.
  • Non-atomic report writes (ReportStore.kt:23,39): File.writeText from the dying crash process can truncate → report silently dropped by scan(). Write-temp + atomic rename.
  • Richtext link-overlap (RichTextEditing.kt:37): applyLink drops partially-overlapping links entirely (un-links the remainder); split instead (as toggleStyle does).
  • Minor: GraphSender.kt:112 reads whole attachment into memory (size guard); RichText.kt:110 mergeSameValueSpans O(n²); DiagnosticsCollector.kt:101 provider-label substring match mislabels mail.notgmail.example as Gmail (non-PII accuracy nit).
Phase-3 review — below-the-cut findings (Backlog, for review): - **Regex recompilation** (`HtmlToText.kt:23-31`): 4 `Regex(...)` literals built per `convert()` call (hot path: once per fetched body during sync). Hoist to `private val`. - **Non-atomic report writes** (`ReportStore.kt:23,39`): `File.writeText` from the dying crash process can truncate → report silently dropped by `scan()`. Write-temp + atomic rename. - **Richtext link-overlap** (`RichTextEditing.kt:37`): `applyLink` drops partially-overlapping links entirely (un-links the remainder); split instead (as `toggleStyle` does). - Minor: `GraphSender.kt:112` reads whole attachment into memory (size guard); `RichText.kt:110` `mergeSameValueSpans` O(n²); `DiagnosticsCollector.kt:101` provider-label substring match mislabels `mail.notgmail.example` as Gmail (non-PII accuracy nit).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#298