Skip to content

Commit 32414e3

Browse files
committed
perf: break early when getting cached playable audios for a yt video
1 parent bfc574e commit 32414e3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/base/audio_handler.dart

+5-1
Original file line numberDiff line numberDiff line change
@@ -1456,14 +1456,18 @@ class NamidaAudioVideoHandler<Q extends Playable> extends BasicAudioHandler<Q> {
14561456

14571457
final newFiles = <AudioCacheDetails>[];
14581458

1459-
for (final fe in Directory(dirPath).listSyncSafe()) {
1459+
final allFiles = Directory(dirPath).listSyncSafe();
1460+
final allLength = allFiles.length;
1461+
for (int i = 0; i < allLength; i++) {
1462+
final fe = allFiles[i];
14601463
final filename = fe.path.getFilename;
14611464
final goodID = filename.startsWith(id);
14621465
final isGood = fe is File && goodID && !filename.endsWith('.part') && !filename.endsWith('.mime');
14631466

14641467
if (isGood) {
14651468
final details = _parseAudioCacheDetailsFromFile(fe);
14661469
newFiles.add(details);
1470+
break; // since its not likely to find other audios
14671471
}
14681472
}
14691473
return newFiles;

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: namida
22
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
33
publish_to: "none"
4-
version: 3.9.23-beta+240816206
4+
version: 3.9.24-beta+240816207
55

66
environment:
77
sdk: ">=3.4.0 <4.0.0"

0 commit comments

Comments
 (0)