Optimize hot paths and eliminate code duplication#47
Conversation
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
Co-authored-by: voxpelli <34457+voxpelli@users.noreply.github.com>
The SonarCloud issue was likely flagging increased cognitive complexity from wrapping the fillQueue logic in a while loop. I've addressed this in commit 1c434e4 by reverting to the recursive approach. The recursive call is actually better here because:
The other optimizations (error normalization helper, generator for array operations, type check refactoring) remain and provide the maintainability improvements without increasing complexity. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|



Identified and addressed performance bottlenecks and duplicated code patterns in the async iterator buffering logic.
Changes
Performance optimizations:
fillQueue()hot path - eliminates repeated allocations when determining least-targeted iteratorCode quality:
normalizeError()utility - consolidates 4 instances of identical error normalizationisValueObject()helper - eliminates duplicate type checks inisIterable()andisAsyncIterable()fillQueue()approach - keeps cognitive complexity low (stack overflow not a concern with typical buffer sizes of 6-10)Configuration:
engines.nodeto>=18.18.0(dependency requirement)@types/chai-quantifiersBefore/After Example
Test coverage improved from 98.45% to 98.59% with no regressions.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.