chore(refactor): optimize memory footprint by extracting inline regex and hardening error handling#291
Merged
ProdigyV21 merged 10 commits intoJun 3, 2026
Conversation
…rmatting instances
…andling - Moved heavily used Regex constants out of functions into companion object in IptvRepository - Refactored xmlAttribute parsing to use optimized string matching instead of dynamic regex in HomeServerRepository - Modernized try-catch into runCatching in StreamRepository - Wrapped volatile Cloud Sync Auth checks in runCatching to avoid flow crashes
…5232904006689' into combined-auto-refactors
…4643912029838459' into combined-auto-refactors # Conflicts: # app/src/main/kotlin/com/arflix/tv/data/repository/IptvRepository.kt
…11037709982985020' into combined-auto-refactors # Conflicts: # app/src/main/kotlin/com/arflix/tv/data/repository/HomeServerRepository.kt # app/src/main/kotlin/com/arflix/tv/data/repository/IptvRepository.kt
…28732041108766665' into combined-auto-refactors # Conflicts: # app/src/main/kotlin/com/arflix/tv/ui/screens/tv/TvViewModel.kt
…08693841350593791' into combined-auto-refactors # Conflicts: # app/src/main/kotlin/com/arflix/tv/ui/screens/player/PlayerScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR combines 5 separate auto-refactoring branches into a single, cohesive update to improve application performance and stability. The primary focus of these changes is to reduce memory allocations and CPU overhead during heavily repeated operations, particularly in string parsing and JSON deserialization.
Key Optimizations
Regex Instantiation Optimization:
Regex(...)instantiations into staticprivate objectorcompanion objectconstants (e.g.,TvVMRegexes,LiveTvScreenRegexes, etc.).Hardened Error Handling:
AppLogger.e(...)calls tocatchblocks that were previously failing silently (such asHero logo fetch failed,warmXtreamVodCachesIfPossible failed).Safer Gson TypeToken Usage:
TypeTokensubclass initializations (e.g.,object : TypeToken<List<...>>() {}.type) to usingTypeToken.getParameterized(...).