Skip to content

Dead code removal 3#79

Merged
GT-610 merged 3 commits into
mainfrom
dead-code-removal-3
Jun 2, 2026
Merged

Dead code removal 3#79
GT-610 merged 3 commits into
mainfrom
dead-code-removal-3

Conversation

@GT-610

@GT-610 GT-610 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

Release Notes

  • Refactoring

    • Optimized internal filtering and data caching for improved performance.
    • Improved lookup logic to eliminate exception-based control flow.
  • Removed Features

    • Removed configuration options for RPC settings, download limits, BT preferences, proxy settings, DHT, tracker sync, and file handling.
    • Removed platform-specific path and home directory utilities.

GT-610 added 2 commits June 2, 2026 18:37
Dead code removal:
- Remove DateTimeX.timestamp getter (unused)
- Remove GhIdX.markdownLink getter (unused)
- Remove Pfs.separator and Pfs.homeDir (unused)
- Remove SettingsService.applySpeedSettingsToBuiltin() (unused)
- Remove 28 unused individual Settings.set*() methods (setRpcListenPort,
  setRpcSecret, setMaxConcurrentDownloads, setSplit, etc.) - only setBtTracker
  and setLastSyncTrackerTime are used by TrackerSyncService

Bug fix:
- Remove redundant client.close() in try block of file selection save handler;
  the finally block already handles cleanup, causing double-close on success
Performance:
- Cache RegExp as static finals in TaskDetailsBtHelpers (azureus pattern,
  digit/letter patterns) instead of recompiling per-peer per-second
- Cache UnmodifiableListView in DownloadDataService.tasks getter (was
  creating a new wrapper on every access, dozens of times per second)
- Precompute lowercase names map before sort in _compareTasks (eliminates
  O(n log n) toLowerCase() allocations per refresh cycle)
- Precompute lowercase instance names map before search filtering (saves
  1x toLowerCase() per task per keystroke)
- Replace firstWhere+catch with simple for-loop in getInstanceById and
  getBuiltinInstance (avoids expensive stack trace capture for control flow)
- Use getBuiltinInstance() in initialize() instead of bare firstWhere
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@GT-610, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 52 minutes and 46 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 39977324-517a-4251-be4b-013f48fa504f

📥 Commits

Reviewing files that changed from the base of the PR and between ca4443f and 663d30a.

📒 Files selected for processing (1)
  • lib/kit/core/platform.dart
📝 Walkthrough

Walkthrough

This PR systematically removes unused extension methods, instance lookup patterns, and settings operations while introducing performance optimizations through caching, precomputation of lookups, and elimination of exception-based control flow. Changes span extension APIs, service layers, and UI download filtering logic.

Changes

API Cleanup and Performance Optimization

Layer / File(s) Summary
Extension API simplification
lib/constants/github_id.dart, lib/kit/core/ext/datetime.dart, lib/kit/core/platform.dart
Removes unused markdownLink from GhIdX, static timestamp from DateTimeX, and separator/homeDir from Pfs; adds instance hourMinute getter to DateTimeX.
Instance manager exception-based to explicit lookup
lib/services/instance_manager.dart
Converts getBuiltinInstance() and getInstanceById() from exception-throwing firstWhere patterns to explicit iteration loops returning null when not found; gates startup connection initiation on successful builtin instance retrieval.
Settings model and service cleanup
lib/models/settings.dart, lib/services/settings_service.dart
Removes 27 unused setter methods from Settings for RPC, download, transfer, BT, proxy, and DHT configuration, and removes applySpeedSettingsToBuiltin() from SettingsService.
Download service task list caching strategy
lib/services/download_data_service.dart
Introduces _tasksView as a cached UnmodifiableListView updated during refresh cycles, exposed via tasks getter to avoid per-access wrapping overhead while maintaining immutability.
Download service case-insensitive sorting optimization
lib/services/download_data_service.dart
Updates _compareTasks to accept a precomputed lowerCaseNames map for case-insensitive name comparison instead of lowercasing during each comparison.
Download page and BT helpers optimization
lib/pages/download_page/download_page.dart, lib/pages/download_page/components/task_details_bt_helpers.dart
Precomputes instance name lookup map in search filtering and precompiles regex patterns for Azureus client parsing and peer version digit/letter classification instead of constructing inline.
Client resource management deferral
lib/pages/download_page/components/task_details_dialog.dart
Removes immediate client.close() after successful file option change, deferring all client shutdown to the finally block.

Possibly related PRs

  • GT-610/setsuna#74: Refactors speed-limit formatting logic in SettingsService around the same method removed in this PR.
  • GT-610/setsuna#76: Modifies the same task list caching and filtering behavior in DownloadDataService and DownloadPage.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Dead code removal 3' accurately reflects the main objective of this pull request, which removes unused methods, getters, and static members across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.


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.

@GT-610 GT-610 merged commit b2d285b into main Jun 2, 2026
@GT-610 GT-610 deleted the dead-code-removal-3 branch June 2, 2026 13:47
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.

1 participant