perf: O(1) dedup/LMC cache, g_slist_append → prepend+reverse

- Add archive_ids hash set and stanza_senders hash map to
  ff_contact_state_t, populated during index build/extend via
  lightweight _ff_cache_line_ids() (no full parse overhead).
- Replace O(n) file scans in _ff_has_archive_id() and
  _ff_find_original_sender() with O(1) hash table lookups.
- Replace g_slist_append with g_slist_prepend + g_slist_reverse
  in _ff_apply_lmc, _flatfile_get_previous_chat, and
  ff_verify_integrity to avoid O(n²) list building.
- Add db_sqlite_last_changes() declaration to database.h.
This commit is contained in:
2026-03-12 10:14:51 +03:00
parent 06463b75b4
commit 71f9ab5007
6 changed files with 146 additions and 86 deletions

View File

@@ -94,6 +94,8 @@ typedef struct
ff_file_stamp_t stamp;
off_t cursor_offset;
int bom_len;
GHashTable* archive_ids; // set: archive_id -> NULL (MAM dedup, O(1))
GHashTable* stanza_senders; // map: stanza_id -> from_jid (LMC validation, O(1))
} ff_contact_state_t;
// State management