mirror of https://github.com/ghostfolio/ghostfolio
Browse Source
Improve redactAttributes() performance by 2.4x (59%) on real-world scenarios. Major optimizations: - Replace JSON.parse(JSON.stringify()) with custom fastClone() function - Implement iterative traversal with pointer-based queue (no recursion) - Separate wildcard and conditional attribute mappings for faster processing - Use Object.keys() instead of for...in for better performance - Cache type checks to reduce repeated typeof operations - Use Map for O(1) attribute lookups Performance improvements: - Real-world portfolios: 2.4x faster (1.182ms → 0.486ms) - Wide objects: 3.3x faster (0.485ms → 0.149ms) - Extreme depth: 1.3x faster (55.914ms → 42.710ms) Benefits: - No breaking changes - same API and behavior - Eliminates recursion risk (no stack overflow) - Better handling of edge cases (circular refs, Big.js) - All existing tests passpull/5843/head
1 changed files with 104 additions and 35 deletions
Loading…
Reference in new issue