Skip to content

Next: Use getParentIndexOf to init HeapAsync#668

Merged
ignlg merged 4 commits intomasterfrom
next
Sep 30, 2025
Merged

Next: Use getParentIndexOf to init HeapAsync#668
ignlg merged 4 commits intomasterfrom
next

Conversation

@ignlg
Copy link
Owner

@ignlg ignlg commented Sep 30, 2025

Summary by CodeRabbit

  • Refactor
    • Optimized initialization logic for asynchronous heap to improve performance. No behavioral or API changes.
  • Documentation
    • Updated changelog with version 2.7.1, noting the optimization.
    • Refreshed generated docs with updated links and minor structural adjustments; no content or API changes.
  • Chores
    • Bumped version to 2.7.1.

@ignlg ignlg self-assigned this Sep 30, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 30, 2025

Walkthrough

Bumps version to 2.7.1, updates changelog/docs, and optimizes HeapAsync.init by changing the heapify starting index computation to use HeapAsync.getParentIndexOf(this.length - 1). No public API changes.

Changes

Cohort / File(s) Summary
HeapAsync init optimization
src/HeapAsync.ts
Adjusts heapify loop start from Math.floor(this.heapArray.length / 2) to HeapAsync.getParentIndexOf(this.length - 1) in HeapAsync.init, iterating down to 0 and calling _sortNodeDown(i).
Version bump and changelog
package.json, README.md, docs/index.html
Version updated 2.7.0 → 2.7.1. Adds 2.7.1 changelog entry: “Optimize loop condition in HeapAsync init method.” Inserts anchor/id for 2.7.1 and minor doc structure tweaks.
Generated docs: link/hash updates
docs/functions/toInt.html, docs/types/Comparator.html, docs/types/IsEqual.html, docs/types/AsyncComparator.html, docs/types/AsyncIsEqual.html
Regenerates HTML with updated “Defined in” commit hashes and minor markup rearrangements; no API or behavioral changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant HeapAsync as HeapAsync
  participant Array as heapArray
  participant Helper as HeapAsync.getParentIndexOf
  participant Node as _sortNodeDown

  User->>HeapAsync: init(items)
  HeapAsync->>heapArray: load items
  HeapAsync->>Helper: getParentIndexOf(length-1)
  Helper-->>HeapAsync: lastParentIndex
  loop i = lastParentIndex down to 0
    HeapAsync->>Node: _sortNodeDown(i)
  end
  HeapAsync-->>User: initialized
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A hop and a heap in version two-seven-one,
I tweak my loops, then I’m neatly done.
Docs get a gloss, the tags align,
Changelogs nibble a tidy line.
With whiskered pride, I thump my feet—
Faster heaps make carrots sweet! 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely highlights the primary change—switching the initialization logic in HeapAsync to use getParentIndexOf—making it easy to understand the main modification at a glance. It specifically names the method and component affected without introducing unrelated noise.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch next

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb03b86 and bf3d739.

⛔ Files ignored due to path filters (2)
  • dist/heap-js.es5.js is excluded by !**/dist/**
  • dist/heap-js.umd.js is excluded by !**/dist/**
📒 Files selected for processing (9)
  • README.md (1 hunks)
  • docs/functions/toInt.html (1 hunks)
  • docs/index.html (2 hunks)
  • docs/types/AsyncComparator.html (1 hunks)
  • docs/types/AsyncIsEqual.html (1 hunks)
  • docs/types/Comparator.html (1 hunks)
  • docs/types/IsEqual.html (1 hunks)
  • package.json (1 hunks)
  • src/HeapAsync.ts (1 hunks)
🔇 Additional comments (4)
package.json (1)

3-3: LGTM! Version bump is appropriate.

The patch version increment from 2.7.0 to 2.7.1 correctly follows semantic versioning for this optimization change.

README.md (1)

46-48: LGTM! Changelog entry is accurate and well-placed.

The changelog entry clearly describes the optimization to the HeapAsync initialization loop condition.

docs/index.html (1)

14-16: LGTM! Documentation updated consistently.

The changelog entry in the generated documentation correctly matches the README.md changes.

src/HeapAsync.ts (1)

434-434: Both Heap and HeapAsync already use getParentIndexOf for heapify start—no changes needed.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

@ignlg ignlg merged commit 41206f6 into master Sep 30, 2025
13 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments