aboutsummaryrefslogtreecommitdiffstats
path: root/components/util/cache.rs
diff options
context:
space:
mode:
authorEmanuel Rylke <ema-fox@web.de>2014-10-14 14:04:03 +0200
committerEmanuel Rylke <ema-fox@web.de>2014-10-16 08:39:51 +0200
commit62595ff448ed9a35c07434dcf5862ecbc65235af (patch)
treec73d5d77a16c97f4d8523497252e5ba51306a69a /components/util/cache.rs
parent9af090006017747809f5f72a8870bd516b20f483 (diff)
downloadservo-62595ff448ed9a35c07434dcf5862ecbc65235af.tar.gz
servo-62595ff448ed9a35c07434dcf5862ecbc65235af.zip
Remove unused implementation of MonoCache
Diffstat (limited to 'components/util/cache.rs')
-rw-r--r--components/util/cache.rs52
1 files changed, 0 insertions, 52 deletions
diff --git a/components/util/cache.rs b/components/util/cache.rs
index 35d442cd079..dd45ee98cc0 100644
--- a/components/util/cache.rs
+++ b/components/util/cache.rs
@@ -18,58 +18,6 @@ pub trait Cache<K: PartialEq, V: Clone> {
fn evict_all(&mut self);
}
-pub struct MonoCache<K, V> {
- entry: Option<(K,V)>,
-}
-
-impl<K: Clone + PartialEq, V: Clone> MonoCache<K,V> {
- pub fn new(_size: uint) -> MonoCache<K,V> {
- MonoCache { entry: None }
- }
-}
-
-impl<K: Clone + PartialEq, V: Clone> Cache<K,V> for MonoCache<K,V> {
- fn insert(&mut self, key: K, value: V) {
- self.entry = Some((key, value));
- }
-
- fn find(&mut self, key: &K) -> Option<V> {
- match self.entry {
- None => None,
- Some((ref k, ref v)) => if *k == *key { Some(v.clone()) } else { None }
- }
- }
-
- fn find_or_create(&mut self, key: &K, blk: |&K| -> V) -> V {
- match self.find(key) {
- Some(value) => value,
- None => {
- let value = blk(key);
- self.entry = Some((key.clone(), value.clone()));
- value
- }
- }
- }
-
- fn evict_all(&mut self) {
- self.entry = None;
- }
-}
-
-#[test]
-fn test_monocache() {
- let mut cache: MonoCache<uint,Cell<&str>> = MonoCache::new(10);
- let one = Cell::new("one");
- let two = Cell::new("two");
- cache.insert(1, one);
-
- assert!(cache.find(&1).is_some());
- assert!(cache.find(&2).is_none());
- cache.find_or_create(&2, |_v| { two });
- assert!(cache.find(&2).is_some());
- assert!(cache.find(&1).is_none());
-}
-
pub struct HashCache<K, V> {
entries: HashMap<K, V>,
}