mirror of
https://github.com/morluto/rea.git
synced 2026-11-23 15:05:51 +00:00
Both entropy counters walked the payload with `for (const byte of bytes)` and accumulated into a `Float64Array` through `counts[byte] ?? 0`. Iterating a typed array that way costs far more than an indexed read, and the nullish fallback is dead work because a typed-array element is never `undefined`. Measured on the compiled function with a 4 MiB block, alternating the two bodies so both run in the same process: | body | time | | --- | --- | | `for...of` + `Float64Array` | 37.15ms | | indexed + `Uint32Array` | 4.64ms | That is **8.01x** on the counter. Entropy values are unchanged: 300 randomised and boundary inputs produce identical results to the previous implementation, and the 4 MiB fixture reports the same entropy from both bodies. `ByteEntropyService` streams the same accounting over each read buffer, so it gets the same change; `filled` bounds that loop because the buffer is reused between reads. `src/domain/native` and `src/application/binaryDiagnostics`: 442 passing. One test fails on this Windows host in both the base and this diff — `reports a changed artifact when its parent directory moves during streaming` fails with `ENOENT` on a directory rename, so it is environmental, not caused by this change. `tsc` 0; `npm run lint` 0 errors; `knip` 0.