perf(server): index profile equipment and research refreshes

Replace O(N^2) linear lookups and repeated array filtering across modifications, weapons, modsResearch and unitResearch with single-pass Map indexes, pre-sort catalogue equipment once on load, avoid redundant pre-change disk writes in PlayerProfiles.updateWhen, and shallow-copy only top-level lists in clientProfile.
This commit is contained in:
N0VAN0M4LY committed 2026-11-30 17:54:36 +08:00
1 parent ebb2937a38
commit 62da2e3038
10 files changed
+401 -155

No files matched your search

+6 -1
View File
@@ -15,7 +15,12 @@ import { clearStoreCart } from './profile-store-cart.ts';
import { serverTimeNow } from './server-time.ts';
export function clientProfile(saved: BlkBlock, account: Account): BlkBlock {
const profile = structuredClone(saved);
// Shallow-copy only the top-level lists; child blocks are never mutated here.
const profile: BlkBlock = {
name: saved.name,
params: [...saved.params],
blocks: [...saved.blocks],
};
clearStoreCart(profile);
const pilotIcon = appearance(profile).pilotIcon || DEFAULT_PILOT_ICON;
setParam(profile, 'pilotIcon', { type: 'string', value: pilotIcon });