Auto merge of #12431 - ice9js:fix/remove-unwrap-calls, r=Wafflespeanut

Remove unnecessary 'unwrap' calls from ImageCacheThread

Fixes #12390.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12390 (github issue number if applicable).

<!-- Either: -->
- [X] These changes do not require tests because the build provides enough verification for the changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12431)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-07-13 03:06:08 -07:00 committed by GitHub
commit d9c9d8d1e3

View file

@ -129,7 +129,7 @@ impl ImageCacheThread {
result_chan: ImageCacheChan, result_chan: ImageCacheChan,
responder: Option<ImageResponder>) { responder: Option<ImageResponder>) {
let msg = ImageCacheCommand::RequestImage(url, result_chan, responder); let msg = ImageCacheCommand::RequestImage(url, result_chan, responder);
self.chan.send(msg).unwrap(); let _ = self.chan.send(msg);
} }
/// Asynchronously request an image and metadata. /// Asynchronously request an image and metadata.
@ -139,7 +139,7 @@ impl ImageCacheThread {
result_chan: ImageCacheChan, result_chan: ImageCacheChan,
responder: Option<ImageResponder>) { responder: Option<ImageResponder>) {
let msg = ImageCacheCommand::RequestImageAndMetadata(url, result_chan, responder); let msg = ImageCacheCommand::RequestImageAndMetadata(url, result_chan, responder);
self.chan.send(msg).unwrap(); let _ = self.chan.send(msg);
} }
/// Get the current state of an image. See ImageCacheCommand::GetImageIfAvailable. /// Get the current state of an image. See ImageCacheCommand::GetImageIfAvailable.
@ -147,8 +147,8 @@ impl ImageCacheThread {
-> Result<Arc<Image>, ImageState> { -> Result<Arc<Image>, ImageState> {
let (sender, receiver) = ipc::channel().unwrap(); let (sender, receiver) = ipc::channel().unwrap();
let msg = ImageCacheCommand::GetImageIfAvailable(url, use_placeholder, sender); let msg = ImageCacheCommand::GetImageIfAvailable(url, use_placeholder, sender);
self.chan.send(msg).unwrap(); let _ = self.chan.send(msg);
receiver.recv().unwrap() try!(receiver.recv().map_err(|_| ImageState::LoadError))
} }
/// Get the current state of an image, returning its metadata if available. /// Get the current state of an image, returning its metadata if available.
@ -157,8 +157,8 @@ impl ImageCacheThread {
-> Result<ImageOrMetadataAvailable, ImageState> { -> Result<ImageOrMetadataAvailable, ImageState> {
let (sender, receiver) = ipc::channel().unwrap(); let (sender, receiver) = ipc::channel().unwrap();
let msg = ImageCacheCommand::GetImageOrMetadataIfAvailable(url, use_placeholder, sender); let msg = ImageCacheCommand::GetImageOrMetadataIfAvailable(url, use_placeholder, sender);
self.chan.send(msg).unwrap(); let _ = self.chan.send(msg);
receiver.recv().unwrap() try!(receiver.recv().map_err(|_| ImageState::LoadError))
} }
/// Decode the given image bytes and cache the result for the given URL. /// Decode the given image bytes and cache the result for the given URL.
@ -166,13 +166,13 @@ impl ImageCacheThread {
url: Url, url: Url,
image_data: Vec<u8>) { image_data: Vec<u8>) {
let msg = ImageCacheCommand::StoreDecodeImage(url, image_data); let msg = ImageCacheCommand::StoreDecodeImage(url, image_data);
self.chan.send(msg).unwrap(); let _ = self.chan.send(msg);
} }
/// Shutdown the image cache thread. /// Shutdown the image cache thread.
pub fn exit(&self) { pub fn exit(&self) {
let (response_chan, response_port) = ipc::channel().unwrap(); let (response_chan, response_port) = ipc::channel().unwrap();
self.chan.send(ImageCacheCommand::Exit(response_chan)).unwrap(); let _ = self.chan.send(ImageCacheCommand::Exit(response_chan));
response_port.recv().unwrap(); let _ = response_port.recv();
} }
} }