Skip to content

Commit 6be5fe2

Browse files
committed
Merge pull request #3425 from killerswan/fix_incoming
(partially fix incoming) More hash function simplification
2 parents 3bd1f32 + a12e90b commit 6be5fe2

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

src/test/bench/core-std.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn read_line() {
6666
fn str_set() {
6767
let r = rand::Rng();
6868

69-
let s = map::hashmap(str::hash, str::eq);
69+
let s = map::hashmap();
7070

7171
for int::range(0, 1000) |_i| {
7272
map::set_add(s, r.gen_str(10));

src/test/bench/graph500-bfs.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ fn make_edges(scale: uint, edgefactor: uint) -> ~[(node_id, node_id)] {
6767
}
6868
}
6969

70-
pure fn node_hash(n: &node_id) -> uint { *n as uint }
71-
7270
fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
7371
let graph = do vec::from_fn(N) |_i| {
74-
map::hashmap::<node_id, ()>(node_hash, sys::shape_eq)
72+
map::hashmap::<node_id, ()>()
7573
};
7674

7775
do vec::each(edges) |e| {
@@ -87,7 +85,7 @@ fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
8785
}
8886

8987
fn gen_search_keys(graph: graph, n: uint) -> ~[node_id] {
90-
let keys = map::hashmap::<node_id, ()>(node_hash, sys::shape_eq);
88+
let keys = map::hashmap::<node_id, ()>();
9189
let r = rand::Rng();
9290

9391
while keys.size() < n {

src/test/bench/task-perf-word-count-generic.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ trait hash_key {
3939
pure fn eq(&&k: self) -> bool;
4040
}
4141

42-
fn mk_hash<K: Const hash_key, V: Copy>() -> map::hashmap<K, V> {
43-
pure fn hashfn<K: Const hash_key>(k: &K) -> uint { k.hash() }
44-
pure fn hasheq<K: Const hash_key>(k1: &K, k2: &K) -> bool { k1.eq(*k2) }
45-
46-
map::hashmap(hashfn, hasheq)
47-
}
48-
4942
impl ~str: hash_key {
5043
pure fn hash() -> uint { str::hash(&self) }
5144
pure fn eq(&&x: ~str) -> bool { self == x }
@@ -175,11 +168,12 @@ mod map_reduce {
175168
input: K1)
176169
{
177170
// log(error, "map_task " + input);
178-
let intermediates = mk_hash();
171+
let intermediates = map::hashmap();
179172

180173
do map(input) |key, val| {
181174
let mut c = None;
182-
match intermediates.find(key) {
175+
let found = intermediates.find(key);
176+
match found {
183177
Some(_c) => { c = Some(_c); }
184178
None => {
185179
do ctrl.swap |ctrl| {
@@ -251,7 +245,7 @@ mod map_reduce {
251245
// This task becomes the master control task. It task::_spawns
252246
// to do the rest.
253247

254-
let reducers = mk_hash();
248+
let reducers = map::hashmap();
255249
let mut tasks = start_mappers(map, ctrl, inputs);
256250
let mut num_mappers = vec::len(inputs) as int;
257251

0 commit comments

Comments
 (0)