Skip to content

Commit 3e8a71f

Browse files
committed
---
yaml --- r: 24025 b: refs/heads/master c: bac89ea h: refs/heads/master i: 24023: 1810748 v: v3
1 parent c342f41 commit 3e8a71f

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: c6ed447221303be59381f91852e0fcd50f60be06
2+
refs/heads/master: bac89eae4844f030b0b3e219e114a1b79212fe7f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/rustc/metadata/common.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,5 @@ enum astencode_tag { // Reserves 0x50 -- 0x6f
123123
tag_table_adjustments = 0x62
124124
}
125125

126-
// djb's cdb hashes.
127-
fn hash_node_id(&&node_id: int) -> uint {
128-
return 177573u ^ (node_id as uint);
129-
}
130-
131-
fn hash_path(&&s: ~str) -> uint {
132-
let mut h = 5381u;
133-
for str::each(s) |ch| { h = (h << 5u) + h ^ (ch as uint); }
134-
return h;
135-
}
136-
137126
type link_meta = {name: ~str, vers: ~str, extras_hash: ~str};
138127

trunk/src/rustc/metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use util::ppaux::ty_to_str;
1616
use syntax::diagnostic::span_handler;
1717
use common::*;
1818
use syntax::parse::token::ident_interner;
19-
19+
use hash::{Hash, HashUtil};
2020

2121
export class_dtor;
2222
export get_class_fields;
@@ -88,7 +88,7 @@ fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
8888
}
8989
lookup_hash(items,
9090
|a| eq_item(a, item_id),
91-
hash_node_id(item_id))
91+
item_id.hash() as uint)
9292
}
9393

9494
fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {

trunk/src/rustc/metadata/encoder.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ use str::to_bytes;
2020
use syntax::ast;
2121
use syntax::diagnostic::span_handler;
2222

23+
use hash::{Hash, HashUtil};
24+
use to_bytes::IterBytes;
25+
2326
export encode_parms;
2427
export encode_metadata;
2528
export encoded_ty;
@@ -679,7 +682,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
679682
}
680683
}
681684
/* Each class has its own index -- encode it */
682-
let bkts = create_index(idx, hash_node_id);
685+
let bkts = create_index(idx);
683686
encode_index(ebml_w, bkts, write_int);
684687
ebml_w.end_tag();
685688

@@ -865,13 +868,13 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::Writer,
865868

866869
// Path and definition ID indexing
867870

868-
fn create_index<T: Copy>(index: ~[entry<T>], hash_fn: fn@(T) -> uint) ->
871+
fn create_index<T: Copy Hash IterBytes>(index: ~[entry<T>]) ->
869872
~[@~[entry<T>]] {
870873
let mut buckets: ~[@mut ~[entry<T>]] = ~[];
871874
for uint::range(0u, 256u) |_i| { vec::push(buckets, @mut ~[]); };
872875
for index.each |elt| {
873-
let h = hash_fn(elt.val);
874-
vec::push(*buckets[h % 256u], elt);
876+
let h = elt.val.hash() as uint;
877+
vec::push(*buckets[h % 256], elt);
875878
}
876879

877880
let mut buckets_frozen = ~[];
@@ -1135,7 +1138,7 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] {
11351138
ecx.stats.item_bytes = wr.pos - i;
11361139

11371140
i = wr.pos;
1138-
let items_buckets = create_index(items_index, hash_node_id);
1141+
let items_buckets = create_index(items_index);
11391142
encode_index(ebml_w, items_buckets, write_int);
11401143
ecx.stats.index_bytes = wr.pos - i;
11411144
ebml_w.end_tag();

0 commit comments

Comments
 (0)