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:
@@ -860,6 +860,14 @@ db_sqlite_rollback_transaction(void)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
db_sqlite_last_changes(void)
|
||||
{
|
||||
if (!g_chatlog_database)
|
||||
return 0;
|
||||
return sqlite3_changes(g_chatlog_database);
|
||||
}
|
||||
|
||||
GSList*
|
||||
db_sqlite_get_all_chat(const gchar* const contact_barejid)
|
||||
{
|
||||
@@ -949,10 +957,10 @@ db_sqlite_list_contacts(void)
|
||||
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
const char* jid = (const char*)sqlite3_column_text(stmt, 0);
|
||||
if (jid && strlen(jid) > 0) {
|
||||
contacts = g_slist_append(contacts, g_strdup(jid));
|
||||
contacts = g_slist_prepend(contacts, g_strdup(jid));
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
return contacts;
|
||||
return g_slist_reverse(contacts);
|
||||
}
|
||||
Reference in New Issue
Block a user