Skip to content

Commit

Permalink
Use FxHashMap for all hash maps
Browse files Browse the repository at this point in the history
  • Loading branch information
neivv committed Mar 20, 2019
1 parent f987e0e commit c2f6439
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aise"
version = "2.21.4"
version = "2.22.0"
authors = ["Markus Heikkinen <ittevien@gmail.com>"]

[lib]
Expand Down Expand Up @@ -40,7 +40,6 @@ thread_local = "0.3.5"

cgmath = { version = "0.16", optional = true }
euclid = { version = "0.19", optional = true }
fnv = { version = "1.0.6", optional = true }
glium = { version = "0.22", optional = true, default-features = false }
gl = { version = "0.10", optional = true }

Expand All @@ -67,4 +66,4 @@ git = "https://github.com/neivv/whack/"
git = "https://github.com/neivv/samase_plugin"

[features]
opengl = ["cgmath", "euclid", "fnv", "font-kit", "glium", "gl"]
opengl = ["cgmath", "euclid", "font-kit", "glium", "gl"]
4 changes: 2 additions & 2 deletions src/gl/text.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::borrow::Cow;
use std::rc::Rc;

use fnv::FnvHashMap;
use font_kit::canvas::{self, Canvas, RasterizationOptions};
use font_kit::font::Font;
use font_kit::hinting::HintingOptions;
use fxhash::FxHashMap;
use glium::backend::Facade;
use glium::texture::{ClientFormat, RawImage2d, Texture2d};

Expand All @@ -22,7 +22,7 @@ pub struct BufferCoord {
struct BufferCoordMap {
// FIXME: Should store glyph ids so chars with equal glyphs don't waste memory
ascii: Vec<Option<BufferCoord>>,
other: FnvHashMap<char, BufferCoord>,
other: FxHashMap<char, BufferCoord>,
}

impl BufferCoordMap {
Expand Down
4 changes: 2 additions & 2 deletions src/idle_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,8 @@ impl InCombatCache {
if recently_attacked {
// Workers need actual non-neutral targets so that they aren't in combat
// from mining cooldown.
let is_mining = unit.id().is_worker() &&
unit.target().map(|x| x.player() == 11).unwrap_or(true);
let is_mining =
unit.id().is_worker() && unit.target().map(|x| x.player() == 11).unwrap_or(true);
if !is_mining {
return true;
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ extern crate cgmath;
#[cfg(feature = "opengl")]
extern crate euclid;
#[cfg(feature = "opengl")]
extern crate fnv;
#[cfg(feature = "opengl")]
extern crate font_kit;
#[cfg(feature = "opengl")]
extern crate gl as opengl;
Expand Down
8 changes: 5 additions & 3 deletions src/unit.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::cell::RefCell;
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use std::ptr::null_mut;

use byteorder::{ReadBytesExt, LE};
use fxhash::FxHashMap;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use bw;
Expand Down Expand Up @@ -111,8 +111,10 @@ impl Iterator for SaveIdMapping {
}

ome2_thread_local! {
SAVE_ID_MAP: RefCell<HashMap<HashableUnit, u32>> = save_mapping(RefCell::new(HashMap::new()));
LOAD_ID_MAP: RefCell<HashMap<u32, Unit>> = load_mapping(RefCell::new(HashMap::new()));
SAVE_ID_MAP: RefCell<FxHashMap<HashableUnit, u32>> =
save_mapping(RefCell::new(FxHashMap::default()));
LOAD_ID_MAP: RefCell<FxHashMap<u32, Unit>> =
load_mapping(RefCell::new(FxHashMap::default()));
}

pub fn init_save_mapping() {
Expand Down

0 comments on commit c2f6439

Please sign in to comment.