mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +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 => {
|
None => {
|
||||||
self.pending_loads.get_by_url(&url).as_ref().
|
let pl = match self.pending_loads.get_by_url(&url) {
|
||||||
map_or(Err(ImageState::NotRequested), |pl| pl.metadata.as_ref().
|
Some(pl) => pl,
|
||||||
map_or(Err(ImageState::Pending), |meta|
|
None => return Err(ImageState::NotRequested),
|
||||||
|
};
|
||||||
|
|
||||||
|
let meta = match pl.metadata {
|
||||||
|
Some(ref meta) => meta,
|
||||||
|
None => return Err(ImageState::Pending),
|
||||||
|
};
|
||||||
|
|
||||||
Ok(ImageOrMetadataAvailable::MetadataAvailable(meta.clone()))
|
Ok(ImageOrMetadataAvailable::MetadataAvailable(meta.clone()))
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue