Skip to content

Refactor to optimize Regex instances for performance and readability - #189

Merged
ProdigyV21 merged 1 commit into
ProdigyV21:mainfrom
Himanth-reddy:coderefactor
May 14, 2026
Merged

Refactor to optimize Regex instances for performance and readability#189
ProdigyV21 merged 1 commit into
ProdigyV21:mainfrom
Himanth-reddy:coderefactor

Conversation

@Himanth-reddy

Copy link
Copy Markdown
Collaborator

Summary of Changes

  • Extracted inline Regex instances in app/src/main/kotlin/com/arflix/tv/ui/components/StreamSelector.kt into a private StreamRegexes object.
  • Extracted inline Regex instances in app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeScreen.kt into a private HomeRegexes object.
  • Extracted inline Regex instances in app/src/main/kotlin/com/arflix/tv/ui/screens/player/PlayerViewModel.kt into a private PlayerRegexes object.

Why this improves the codebase

  • Pre-compiling Regex objects into singleton objects avoids the expensive cost of recompiling the pattern multiple times, significantly improving parsing and string manipulation performance (which frequently runs on large streaming datasets).
  • Code is cleaner and more readable by having Regex patterns defined together.

Verification

  • Code compiles successfully.
  • No business logic was altered.
  • Automated tests pass (existing tests unrelated to the changes that fail have been ignored per guidelines).

Summary of Changes
* Extracted inline `Regex` instances in `app/src/main/kotlin/com/arflix/tv/ui/components/StreamSelector.kt` into a private `StreamRegexes` object.
* Extracted inline `Regex` instances in `app/src/main/kotlin/com/arflix/tv/ui/screens/home/HomeScreen.kt` into a private `HomeRegexes` object.
* Extracted inline `Regex` instances in `app/src/main/kotlin/com/arflix/tv/ui/screens/player/PlayerViewModel.kt` into a private `PlayerRegexes` object.

Why this improves the codebase
* Pre-compiling `Regex` objects into singleton objects avoids the expensive cost of recompiling the pattern multiple times, significantly improving parsing and string manipulation performance (which frequently runs on large streaming datasets).
* Code is cleaner and more readable by having Regex patterns defined together.

Verification
- [x] Code compiles successfully.
- [x] No business logic was altered.
- [x] Automated tests pass (existing tests unrelated to the changes that fail have been ignored per guidelines).
@ProdigyV21
ProdigyV21 merged commit 7f3124d into ProdigyV21:main May 14, 2026
1 check passed
@Himanth-reddy Himanth-reddy added gssoc-approved level:intermediate Intermediate level task quality:clean Clean code implementation type:refactor Code refactoring and cleanups type:performance Performance optimization gssoc:approved GSSoC approved contribution and removed gssoc:approved 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:intermediate Intermediate 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