Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
faster content hash computation via in memory sorting
zadam620e896a8926
diff --git a/src/services/content_hash.js b/src/services/content_hash.jsindex 6946cc33bc..47ae6e5354 100644--- a/src/services/content_hash.js+++ b/src/services/content_hash.js@@ -12,9 +12,11 @@ const RecentNote = require('../entities/recent_note');const Option = require('../entities/option');function getSectorHashes(tableName, primaryKeyName, whereBranch) {- const hashes = sql.getRows(`SELECT ${primaryKeyName} AS id, hash FROM ${tableName} `- + (whereBranch ? `WHERE ${whereBranch} ` : '')- + ` ORDER BY ${primaryKeyName}`);+ const hashes = sql.getRows(`SELECT ${primaryKeyName} AS id, hash FROM ${tableName}`+ + (whereBranch ? ` WHERE ${whereBranch} ` : ''));++ // sorting is faster in memory+ hashes.sort((a, b) => a.id < b.id ? -1 : 1);const map = {};