Skip to content

feat: [performance improvement] Optimize schedule filtering with Set lookup#259

Open
anyulled wants to merge 1 commit into
mainfrom
perf-optimize-schedule-filter-set-237839672946295760
Open

feat: [performance improvement] Optimize schedule filtering with Set lookup#259
anyulled wants to merge 1 commit into
mainfrom
perf-optimize-schedule-filter-set-237839672946295760

Conversation

@anyulled
Copy link
Copy Markdown
Owner

@anyulled anyulled commented Jun 4, 2026

💡 What: Replaced an Array.prototype.includes check with a Set.prototype.has lookup within the schedule filtering logic in components/schedule/ScheduleContainer.tsx.
🎯 Why: The filtering function iterates over all sessions across all rooms and timeslots. Using includes on an array results in O(N*M) time complexity. Using a Set improves this to O(N+M), preventing performance degradation as a user saves more sessions.
📊 Impact: Improves filtering performance and prevents UI lag when toggling the "My Schedule" view with a large number of saved sessions.
🔬 Measurement: The improvement can be verified by observing the time taken to filter the schedule, particularly when the user has favorited a significant number of talks.


PR created automatically by Jules for task 237839672946295760 started by @anyulled

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced schedule filtering logic to improve accuracy and performance when displaying saved and service sessions.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
devbcn-nextjs Error Error Jun 4, 2026 8:26am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8e7e0d3d-b8a1-4271-addc-f98da16c8902

📥 Commits

Reviewing files that changed from the base of the PR and between 0307ff3 and 9384c31.

📒 Files selected for processing (1)
  • components/schedule/ScheduleContainer.tsx

📝 Walkthrough

Walkthrough

ScheduleContainer optimizes session filtering by converting the savedSessionIds array to a Set for O(1) membership checks, replacing the previous array .includes() call with .has() while preserving the filtering logic for saved sessions or service sessions.

Changes

Schedule filter performance optimization

Layer / File(s) Summary
Schedule filter Set optimization
components/schedule/ScheduleContainer.tsx
savedIdsSet is derived from savedSessionIds using new Set(), and the filter condition is updated to use savedIdsSet.has(s.id) instead of savedSessionIds.includes(s.id) for faster O(1) lookups. Service sessions remain included via the s.isServiceSession condition.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

size/XS

Poem

🐰 A speedy set replaces the array,
Where membership checks used to delay,
O(one) beats O(n) every day,
Sessions filter the swift rabbit way! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: optimizing schedule filtering by converting array includes to Set lookup for better performance.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf-optimize-schedule-filter-set-237839672946295760

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: dependency version conflict. Check your lock file or package.json.


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

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

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request optimizes session filtering in ScheduleContainer.tsx by converting savedSessionIds into a Set to achieve O(1) lookup times. The reviewer recommended defensively checking if savedSessionIds is an array before instantiating the Set to prevent potential runtime crashes from corrupted localStorage data.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

}

const filterSessions = (sessions: GridSession[]) => sessions.filter((s) => savedSessionIds.includes(s.id) || s.isServiceSession);
const savedIdsSet = new Set(savedSessionIds);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To prevent potential runtime crashes, it is safer to defensively verify that savedSessionIds is an array before passing it to new Set(). Since savedSessionIds is loaded from localStorage in ScheduleProvider without explicit validation that the parsed JSON is indeed an array, any corrupted or non-array value (such as an object {}) in localStorage would cause new Set(savedSessionIds) to throw a TypeError and crash the application.

Suggested change
const savedIdsSet = new Set(savedSessionIds);
const savedIdsSet = new Set(Array.isArray(savedSessionIds) ? savedSessionIds : []);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant