aacc7336d7
Six hot-path optimizations that reduce per-frame CPU cost: 1. Waterfall color LUT: Pre-compute a 256-entry RGBA lookup table (bins are i8 = 256 possible values) instead of calling waterfallColorRgba() per-pixel with HSL→RGB math + Math.pow(). Eliminates ~2000+ HSL conversions per frame across both waterfalls. 2. Noise floor O(N)→O(N log N): Replace .slice().sort() with an in-place quickselect algorithm for 15th-percentile estimation. For 1024 bins this is ~10× faster. 3. Reuse spectrum bin buffers: SSE handler and buildSpectrumRenderData now reuse pre-allocated arrays instead of creating new Array(N) and .map() allocations every frame. Reduces GC pressure. 4. Cache canvas dimensions: drawSpectrum and drawSpectrumWaterfall read cached CSS dimensions instead of querying clientWidth/ clientHeight every frame (which forces layout recalculation). Dimensions refreshed on resize and layout changes. 5. Cache DOM references: getElementById calls for zoom indicator and minimap elements moved to module-level constants instead of querying the DOM on every drawSpectrum call. 6. Efficient array trimming: Peak hold pruning uses in-place splice from front instead of .filter() (which allocates a new array). Waterfall row trimming uses splice instead of repeated .shift(). https://claude.ai/code/session_01G6wuNCkckbHHsU7w5zCtW2 Signed-off-by: Claude <noreply@anthropic.com>