once-map: avoid hard-coding Arc (#3242)

The only thing a `OnceMap` really needs to be able to do with the value
is to clone it. All extant uses benefited from having this done for them
by automatically wrapping values in an `Arc`. But this isn't necessarily
true for all things. For example, a value might have an `Arc` internally
to making cloning cheap in other contexts, and it doesn't make sense to
re-wrap it in an `Arc` just to use it with a `OnceMap`. Or
alternatively, cloning might just be cheap enough on its own that an
`Arc` isn't worth it.
This commit is contained in:
Andrew Gallant 2024-04-24 11:11:46 -04:00 committed by GitHub
parent 67d8805ca8
commit 0b84eb0140
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 25 deletions

View file

@ -312,13 +312,12 @@ impl AuthMiddleware {
);
if !self.cache().fetches.register(key.clone()) {
let credentials = Arc::<_>::unwrap_or_clone(
self.cache()
.fetches
.wait(&key)
.await
.expect("The key must exist after register is called"),
);
let credentials = self
.cache()
.fetches
.wait(&key)
.await
.expect("The key must exist after register is called");
if credentials.is_some() {
trace!("Using credentials from previous fetch for {url}");