Skip to content
This repository was archived by the owner on Aug 21, 2026. It is now read-only.

perf: remove destructuring in resolveState hot path - #33

Open
Farenheith wants to merge 2 commits into
masterfrom
fix/remove-destructuring-resolveState
Open

perf: remove destructuring in resolveState hot path#33
Farenheith wants to merge 2 commits into
masterfrom
fix/remove-destructuring-resolveState

Conversation

@Farenheith

Copy link
Copy Markdown
Member

Summary

Remove object destructuring in resolveState hot path to eliminate O(N×M) heap allocations per next() call.

Changes

  • Sync lib (lib/augmentative-iterable.js): Replace const { action, type } = augmentList[ai] with indexed access
  • Async lib (lib/augmentative-async-iterable.js): Same optimization for async resolveState

Performance Impact

Benchmark Improvement
addMap gen→arr ↓ 31%
addFilter+addMap gen→arr ↓ 28%
addMap arr→arr ↓ 15%
addFilter+addMap arr→arr ↓ 12%

Testing

  • All augmentative-iterable edge cases pass (empty, single element, TakeWhile, Skip, chained ops, generators, async)
  • All fluent-iterable unit tests pass (1778 tests across 43 test suites)
  • No regression in performance

Replace object destructuring with indexed access to avoid O(N×M)
heap allocations per next() call. Benchmark shows 12-31% improvement
depending on workload.
@Farenheith
Farenheith force-pushed the master branch 2 times, most recently from b3c3ec1 to d7fb48b Compare August 16, 2026 10:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant