Skip to content

Commit

Permalink
Upgrade to new Hasher API
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuda committed Feb 3, 2016
1 parent b1fffcd commit 95be0b9
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 20 deletions.
7 changes: 3 additions & 4 deletions components/gfx/font_context.rs
Expand Up @@ -19,9 +19,8 @@ use platform::font_template::FontTemplateData;
use smallvec::SmallVec;
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::hash_state::DefaultState;
use std::default::Default;
use std::hash::{Hash, Hasher};
use std::hash::{BuildHasherDefault, Hash, Hasher};
use std::rc::Rc;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
Expand Down Expand Up @@ -86,7 +85,7 @@ pub struct FontContext {
paint_font_cache: Vec<PaintFontCacheEntry>,

layout_font_group_cache:
HashMap<LayoutFontGroupCacheKey, Rc<FontGroup>, DefaultState<FnvHasher>>,
HashMap<LayoutFontGroupCacheKey, Rc<FontGroup>, BuildHasherDefault<FnvHasher>>,

epoch: usize,
}
Expand All @@ -100,7 +99,7 @@ impl FontContext {
layout_font_cache: vec!(),
fallback_font_cache: vec!(),
paint_font_cache: vec!(),
layout_font_group_cache: HashMap::with_hash_state(Default::default()),
layout_font_group_cache: HashMap::with_hasher(Default::default()),
epoch: 0,
}
}
Expand Down
1 change: 0 additions & 1 deletion components/gfx/lib.rs
Expand Up @@ -10,7 +10,6 @@
#![feature(box_syntax)]
#![feature(custom_attribute)]
#![feature(custom_derive)]
#![feature(hashmap_hasher)]
#![feature(mpsc_select)]
#![feature(plugin)]
#![feature(str_char)]
Expand Down
4 changes: 2 additions & 2 deletions components/layout/context.rs
Expand Up @@ -20,7 +20,7 @@ use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResp
use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
use std::cell::{RefCell, RefMut};
use std::collections::HashMap;
use std::collections::hash_state::DefaultState;
use std::hash::BuildHasherDefault;
use std::rc::Rc;
use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -95,7 +95,7 @@ pub struct SharedLayoutContext {
pub canvas_layers_sender: Mutex<Sender<(LayerId, IpcSender<CanvasMsg>)>>,

/// The visible rects for each layer, as reported to us by the compositor.
pub visible_rects: Arc<HashMap<LayerId, Rect<Au>, DefaultState<FnvHasher>>>,
pub visible_rects: Arc<HashMap<LayerId, Rect<Au>, BuildHasherDefault<FnvHasher>>>,
}

pub struct LayoutContext<'a> {
Expand Down
8 changes: 4 additions & 4 deletions components/layout/layout_thread.rs
Expand Up @@ -54,7 +54,7 @@ use serde_json;
use std::borrow::ToOwned;
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::hash_state::DefaultState;
use std::hash::BuildHasherDefault;
use std::ops::{Deref, DerefMut};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::{channel, Sender, Receiver};
Expand Down Expand Up @@ -195,7 +195,7 @@ pub struct LayoutThread {

/// The position and size of the visible rect for each layer. We do not build display lists
/// for any areas more than `DISPLAY_PORT_SIZE_FACTOR` screens away from this area.
visible_rects: Arc<HashMap<LayerId, Rect<Au>, DefaultState<FnvHasher>>>,
visible_rects: Arc<HashMap<LayerId, Rect<Au>, BuildHasherDefault<FnvHasher>>>,

/// The list of currently-running animations.
running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
Expand Down Expand Up @@ -430,7 +430,7 @@ impl LayoutThread {
new_animations_receiver: new_animations_receiver,
outstanding_web_fonts: outstanding_web_fonts_counter,
root_flow: None,
visible_rects: Arc::new(HashMap::with_hash_state(Default::default())),
visible_rects: Arc::new(HashMap::with_hasher(Default::default())),
running_animations: Arc::new(RwLock::new(HashMap::new())),
expired_animations: Arc::new(RwLock::new(HashMap::new())),
epoch: Epoch(0),
Expand Down Expand Up @@ -1099,7 +1099,7 @@ impl LayoutThread {
// layers have moved more than `DISPLAY_PORT_THRESHOLD_SIZE_FACTOR` away from their last
// positions.
let mut must_regenerate_display_lists = false;
let mut old_visible_rects = HashMap::with_hash_state(Default::default());
let mut old_visible_rects = HashMap::with_hasher(Default::default());
let inflation_amount =
Size2D::new(self.viewport_size.width * DISPLAY_PORT_THRESHOLD_SIZE_FACTOR,
self.viewport_size.height * DISPLAY_PORT_THRESHOLD_SIZE_FACTOR);
Expand Down
1 change: 0 additions & 1 deletion components/layout/lib.rs
Expand Up @@ -6,7 +6,6 @@
#![feature(box_syntax)]
#![feature(cell_extras)]
#![feature(custom_derive)]
#![feature(hashmap_hasher)]
#![feature(mpsc_select)]
#![feature(nonzero)]
#![feature(plugin)]
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/eventtarget.rs
Expand Up @@ -28,9 +28,9 @@ use js::rust::{AutoObjectVectorWrapper, CompileOptionsWrapper};
use libc::{c_char, size_t};
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::hash_state::DefaultState;
use std::default::Default;
use std::ffi::CString;
use std::hash::BuildHasherDefault;
use std::rc::Rc;
use std::{intrinsics, ptr};
use string_cache::Atom;
Expand Down Expand Up @@ -161,7 +161,7 @@ pub struct EventListenerEntry {
#[dom_struct]
pub struct EventTarget {
reflector_: Reflector,
handlers: DOMRefCell<HashMap<Atom, Vec<EventListenerEntry>, DefaultState<FnvHasher>>>,
handlers: DOMRefCell<HashMap<Atom, Vec<EventListenerEntry>, BuildHasherDefault<FnvHasher>>>,
}

impl EventTarget {
Expand Down
1 change: 0 additions & 1 deletion components/script/lib.rs
Expand Up @@ -12,7 +12,6 @@
#![feature(custom_attribute)]
#![feature(custom_derive)]
#![feature(fnbox)]
#![feature(hashmap_hasher)]
#![feature(mpsc_select)]
#![feature(nonzero)]
#![feature(on_unimplemented)]
Expand Down
7 changes: 3 additions & 4 deletions components/util/cache.rs
Expand Up @@ -6,9 +6,8 @@ use rand;
use rand::Rng;
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::hash_state::DefaultState;
use std::default::Default;
use std::hash::{Hash, Hasher, SipHasher};
use std::hash::{BuildHasherDefault, Hash, Hasher, SipHasher};
use std::slice::Iter;


Expand All @@ -17,7 +16,7 @@ pub struct HashCache<K, V>
where K: Clone + PartialEq + Eq + Hash,
V: Clone,
{
entries: HashMap<K, V, DefaultState<SipHasher>>,
entries: HashMap<K, V, BuildHasherDefault<SipHasher>>,
}

impl<K, V> HashCache<K, V>
Expand All @@ -26,7 +25,7 @@ impl<K, V> HashCache<K, V>
{
pub fn new() -> HashCache<K, V> {
HashCache {
entries: HashMap::with_hash_state(<DefaultState<SipHasher> as Default>::default()),
entries: HashMap::with_hasher(Default::default()),
}
}

Expand Down
1 change: 0 additions & 1 deletion components/util/lib.rs
Expand Up @@ -8,7 +8,6 @@
#![feature(custom_derive)]
#![cfg_attr(feature = "non-geckolib", feature(decode_utf16))]
#![feature(fnbox)]
#![feature(hashmap_hasher)]
#![feature(heap_api)]
#![feature(oom)]
#![feature(optin_builtin_traits)]
Expand Down

0 comments on commit 95be0b9

Please sign in to comment.