mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
Optimization: Box fut Remote::get_redirected_final_url
in GhCrateMeta::find
(#600)
* Box fut `Remote::get_redirected_final_url` in `GhCrateMeta::find` Since the other await point in `GhCrateMeta::find` only needs `Arc<Self>` and `handles` to be saved, which is much smaller than the future returned by `Remote::get_redirected_final_url` * Refactor: Simplify `wait_on_cancellation_signal` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
647e340d38
commit
73a794dc13
2 changed files with 4 additions and 12 deletions
|
@ -86,11 +86,7 @@ impl super::Fetcher for GhCrateMeta {
|
|||
fn find(self: Arc<Self>) -> AutoAbortJoinHandle<Result<bool, BinstallError>> {
|
||||
AutoAbortJoinHandle::spawn(async move {
|
||||
let repo = if let Some(repo) = self.data.repo.as_deref() {
|
||||
Some(
|
||||
self.client
|
||||
.get_redirected_final_url(Url::parse(repo)?)
|
||||
.await?,
|
||||
)
|
||||
Some(Box::pin(self.client.get_redirected_final_url(Url::parse(repo)?)).await?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
@ -41,16 +41,12 @@ fn ignore_signals() -> io::Result<()> {
|
|||
/// that also returns `Ok(())`.
|
||||
async fn wait_on_cancellation_signal() -> Result<(), io::Error> {
|
||||
#[cfg(unix)]
|
||||
async fn inner() -> Result<(), io::Error> {
|
||||
unix::wait_on_cancellation_signal_unix().await
|
||||
}
|
||||
unix::wait_on_cancellation_signal_unix().await?;
|
||||
|
||||
#[cfg(not(unix))]
|
||||
async fn inner() -> Result<(), io::Error> {
|
||||
signal::ctrl_c().await
|
||||
}
|
||||
signal::ctrl_c().await?;
|
||||
|
||||
inner().await
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue