Skip to content

Commit 6dbe893

Browse files
committed
perf(Music): optimize progress update handling
- Simplified the progress update logic by removing unnecessary closure. - Directly updated the progress object and rendered it in the main function. - Improved code readability and performance by reducing function calls.
1 parent fc33ae7 commit 6dbe893

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

app/Music.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,12 @@ public function download(string $url, string $savedPath): void
9696
$progress = tap(progress($savedPath, $totalDownload))->start();
9797
}
9898

99-
value(static function (Progress $progress, int $downloaded): void {
100-
$progress->progress = $downloaded;
101-
$progress->render();
102-
}, $progress, $downloaded);
103-
10499
if ($totalDownload === $downloaded) {
105100
$progress->finish();
106101
}
102+
103+
$progress->progress = $downloaded;
104+
$progress->render();
107105
},
108106
]);
109107
}

0 commit comments

Comments
 (0)