Remove UrlMap<T>, just use HashMap<rust_url::Url, T>

This commit is contained in:
Simon Sapin 2014-07-19 18:02:43 +01:00
parent 447655144d
commit b902e0f8f5
3 changed files with 8 additions and 16 deletions

View file

@ -5,9 +5,9 @@
use image::base::{Image, load_from_memory};
use resource_task;
use resource_task::{LoadData, ResourceTask};
use servo_util::url::{UrlMap, url_map};
use std::comm::{channel, Receiver, Sender};
use std::collections::hashmap::HashMap;
use std::mem::replace;
use std::task::spawn;
use std::result;
@ -88,8 +88,8 @@ impl ImageCacheTask {
resource_task: resource_task.clone(),
port: port,
chan: chan_clone,
state_map: url_map(),
wait_map: url_map(),
state_map: HashMap::new(),
wait_map: HashMap::new(),
need_exit: None
};
cache.run();
@ -136,9 +136,9 @@ struct ImageCache {
/// A copy of the shared chan to give to child tasks
chan: Sender<Msg>,
/// The state of processsing an image for a URL
state_map: UrlMap<ImageState>,
state_map: HashMap<Url, ImageState>,
/// List of clients waiting on a WaitForImage response
wait_map: UrlMap<Arc<Mutex<Vec<Sender<ImageResponseMsg>>>>>,
wait_map: HashMap<Url, Arc<Mutex<Vec<Sender<ImageResponseMsg>>>>>,
need_exit: Option<Sender<()>>,
}

View file

@ -12,7 +12,7 @@ use image_cache_task::{Decode, GetImage, ImageCacheTask, ImageFailed, ImageNotRe
use image_cache_task::{ImageResponseMsg, Prefetch, WaitForImage};
use std::comm::{Receiver, channel};
use servo_util::url::{UrlMap, url_map};
use std::collections::hashmap::HashMap;
use servo_util::task::spawn_named;
use url::Url;
@ -24,7 +24,7 @@ pub struct LocalImageCache {
image_cache_task: ImageCacheTask,
round_number: uint,
on_image_available: Option<Box<ImageResponder+Send>>,
state_map: UrlMap<ImageState>
state_map: HashMap<Url, ImageState>
}
impl LocalImageCache {
@ -33,7 +33,7 @@ impl LocalImageCache {
image_cache_task: image_cache_task,
round_number: 1,
on_image_available: None,
state_map: url_map()
state_map: HashMap::new()
}
}
}

View file

@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::collections::hashmap::HashMap;
use rust_url;
use rust_url::{Url, UrlParser};
@ -31,13 +30,6 @@ pub fn parse_url(str_url: &str, base_url: Option<rust_url::Url>) -> rust_url::Ur
}
pub type UrlMap<T> = HashMap<rust_url::Url, T>;
pub fn url_map<T: Clone + 'static>() -> UrlMap<T> {
HashMap::new()
}
pub fn is_image_data(uri: &str) -> bool {
static types: &'static [&'static str] = &["data:image/png", "data:image/gif", "data:image/jpeg"];
types.iter().any(|&type_| uri.starts_with(type_))