faster content hash computation via in memory sorting

This commit is contained in:
zadam 2020-10-02 21:53:25 +02:00
parent a9a9edf658
commit 620e896a89

View File

@ -13,8 +13,10 @@ 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}`);
+ (whereBranch ? ` WHERE ${whereBranch} ` : ''));
// sorting is faster in memory
hashes.sort((a, b) => a.id < b.id ? -1 : 1);
const map = {};