Performance: Buffer concatenation
MEDIUM IMPACT
This affects how fast Node.js can combine multiple binary data chunks, impacting memory usage and CPU time during data processing.
const result = Buffer.concat(chunks);
let result = Buffer.alloc(0); for (const chunk of chunks) { result = Buffer.concat([result, chunk]); }
| Pattern | Memory Allocations | CPU Copies | Latency Impact | Verdict |
|---|---|---|---|---|
| Repeated Buffer.concat in loop | Multiple allocations | Multiple copies | High latency due to quadratic copying | [X] Bad |
| Single Buffer.concat call | One allocation | One copy | Low latency with linear copying | [OK] Good |