Skip to content

perf(sorted_set): optimize union and symmetric_difference#3311

Closed
bobzhang wants to merge 1 commit intomainfrom
hongbo/sorted-set-optimize
Closed

perf(sorted_set): optimize union and symmetric_difference#3311
bobzhang wants to merge 1 commit intomainfrom
hongbo/sorted-set-optimize

Conversation

@bobzhang
Copy link
Copy Markdown
Contributor

@bobzhang bobzhang commented Mar 19, 2026

Summary

  • union: Replace full tree traversal (each) for size counting with a direct recursive count function. Removes the TODO comment.
  • symmetric_difference: Build result directly in a single pass over both sets instead of creating two intermediate difference sets then calling union. Removes the TODO comment.

Test plan

  • moon check passes
  • All 48 sorted_set tests pass

🤖 Generated with Claude Code


Open with Devin

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Mar 19, 2026

Pull Request Test Coverage Report for Build 3071

Details

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 95.717%

Totals Coverage Status
Change from base Build 3070: 0.001%
Covered Lines: 13765
Relevant Lines: 14381

💛 - Coveralls

@bobzhang bobzhang force-pushed the hongbo/sorted-set-optimize branch 3 times, most recently from 2a7be29 to 072c29d Compare March 19, 2026 14:48
union: replace full tree traversal for size counting with a direct
  count function, removing the TODO about avoiding size counting
symmetric_difference: build result directly in a single pass instead
  of creating two intermediate sets then merging them

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bobzhang bobzhang force-pushed the hongbo/sorted-set-optimize branch from 072c29d to f3d1304 Compare March 19, 2026 23:50
@bobzhang
Copy link
Copy Markdown
Contributor Author

Closing in favor of #3315 which provides the genuinely algorithmic O(n+m) improvement. This PR's changes (count function, symmetric_difference rewrite) are superseded — the count function is the same O(n) as the original each-based approach, and #3315 rewrites symmetric_difference with the split-based algorithm.

@bobzhang bobzhang closed this Mar 20, 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.

2 participants