Skip to content

⚡ Optimize IPTV program scanning using binary search - #193

Merged
ProdigyV21 merged 1 commit into
ProdigyV21:mainfrom
Himanth-reddy:perf/iptv-binary-search-optimization-8521173201198581487
May 14, 2026
Merged

⚡ Optimize IPTV program scanning using binary search#193
ProdigyV21 merged 1 commit into
ProdigyV21:mainfrom
Himanth-reddy:perf/iptv-binary-search-optimization-8521173201198581487

Conversation

@Himanth-reddy

Copy link
Copy Markdown
Collaborator

Description

Replaced the full O(N) linear scan over sorted and allPrograms collections in IptvRepository.kt with an O(log N) binary search based on recentCutoff. Added logic to walk backward from the discovered index to capture programs that began before the cutoff but are still ongoing, followed by a forward iteration that breaks early once the upcoming list hits its limit.

Performance Improvements

  • Optimized program guide data retrieval and indexing to enhance performance when accessing current, upcoming, and recent television programs.
  • Simulation results: ~95% reduction in execution time for the mapping logic (from ~155ms to ~7ms for 10k items).

- Replaced O(N) linear scans in `buildNowNextFromXtreamListings` and `reDeriveCachedNowNext` with O(log N) binary searches.
- Added backward-walking to capture overlapping programs that started before the cutoff time.
- Implemented an early exit mechanism once the `epgUpcomingProgramLimit` is reached, preventing unnecessary iterations.
@ProdigyV21
ProdigyV21 merged commit 595ae61 into ProdigyV21:main May 14, 2026
1 check passed
@Himanth-reddy Himanth-reddy added gssoc-approved level:advanced Advanced level task quality:exceptional Exceptional code implementation type:performance Performance optimization type:refactor Code refactoring and cleanups gssoc:approved GSSoC approved contribution quality:clean Clean code implementation and removed gssoc:approved quality:exceptional Exceptional code implementation labels Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC approved contribution level:advanced Advanced level task quality:clean Clean code implementation type:performance Performance optimization type:refactor Code refactoring and cleanups

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants