mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Bonus fix: Rewrite get_image_or_meta_if_available in an imperative style.
I believe this is more readable.
This commit is contained in:
parent
1064c3dca0
commit
d5b559c37c
1 changed files with 11 additions and 6 deletions
|
@ -554,12 +554,17 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
None => {
|
||||
self.pending_loads.get_by_url(&url).as_ref().
|
||||
map_or(Err(ImageState::NotRequested), |pl| pl.metadata.as_ref().
|
||||
map_or(Err(ImageState::Pending), |meta|
|
||||
let pl = match self.pending_loads.get_by_url(&url) {
|
||||
Some(pl) => pl,
|
||||
None => return Err(ImageState::NotRequested),
|
||||
};
|
||||
|
||||
let meta = match pl.metadata {
|
||||
Some(ref meta) => meta,
|
||||
None => return Err(ImageState::Pending),
|
||||
};
|
||||
|
||||
Ok(ImageOrMetadataAvailable::MetadataAvailable(meta.clone()))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue