servo: Restructure ImageCache.get_image

Source-Repo: https://github.com/servo/servo
Source-Revision: 2fa203bc72be76639184928a62be39f4c744926a
This commit is contained in:
Brian Anderson 2012-08-10 16:37:30 -07:00
Родитель 41c0bf7c9a
Коммит 91720428ec
1 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -84,6 +84,14 @@ impl ImageCache {
} }
/*priv*/ fn get_image(url: url, response: chan<ImageResponseMsg>) { /*priv*/ fn get_image(url: url, response: chan<ImageResponseMsg>) {
match self.image_map.find(url) {
some(image) => {
response.send(ImageReady(clone_arc(image)));
return
}
none => ()
}
match self.prefetch_map.find(url) { match self.prefetch_map.find(url) {
some(prefetch_data) => { some(prefetch_data) => {
@ -118,13 +126,7 @@ impl ImageCache {
response.send(ImageNotReady); response.send(ImageNotReady);
} }
} }
none => { none => fail ~"got a request for image data without prefetch"
// FIXME: Probably faster to hit this map before the prefetch map
match self.image_map.find(url) {
some(image) => response.send(ImageReady(clone_arc(image))),
none => fail ~"got a request for image data without prefetch"
}
}
} }
} }
} }