Skip to content

Commit b562264

Browse files
committed
---
yaml --- r: 24533 b: refs/heads/try2 c: 742c05f h: refs/heads/master i: 24531: ed01c6d v: v3
1 parent f8dff2e commit b562264

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 7762c80d1b25434ad9346ae77a5d08a58f7d05ba
8+
refs/heads/try2: 742c05f87d51e28a1fa020070554c0e9c292a4e5
99
refs/heads/incoming: 05543fd04dfb3f63b453a331e239ceb1a9a219f9
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/rustc/metadata/decoder.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export translate_def_id;
5959
// what crate that's in and give us a def_id that makes sense for the current
6060
// build.
6161

62-
fn lookup_hash(d: ebml::doc, eq_fn: fn@(~[u8]) -> bool, hash: uint) ->
62+
fn lookup_hash(d: ebml::doc, eq_fn: fn@(x:&[u8]) -> bool, hash: uint) ->
6363
~[ebml::doc] {
6464
let index = ebml::get_doc(d, tag_index);
6565
let table = ebml::get_doc(index, tag_index_table);
@@ -72,16 +72,17 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn@(~[u8]) -> bool, hash: uint) ->
7272
let belt = tag_index_buckets_bucket_elt;
7373
do ebml::tagged_docs(bucket, belt) |elt| {
7474
let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint;
75-
if eq_fn(vec::slice::<u8>(*elt.data, elt.start + 4u, elt.end)) {
75+
if eq_fn(vec::view::<u8>(*elt.data, elt.start + 4u, elt.end)) {
7676
vec::push(result, ebml::doc_at(d.data, pos).doc);
7777
}
7878
};
7979
ret result;
8080
}
8181

8282
fn maybe_find_item(item_id: int, items: ebml::doc) -> option<ebml::doc> {
83-
fn eq_item(bytes: ~[u8], item_id: int) -> bool {
84-
ret io::u64_from_be_bytes(bytes, 0u, 4u) as int == item_id;
83+
fn eq_item(bytes: &[u8], item_id: int) -> bool {
84+
ret io::u64_from_be_bytes(vec::slice(bytes, 0u, 4u), 0u, 4u) as int
85+
== item_id;
8586
}
8687
let eqer = |a| eq_item(a, item_id);
8788
let found = lookup_hash(items, eqer, hash_node_id(item_id));
@@ -215,8 +216,21 @@ fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] {
215216
// Given a path and serialized crate metadata, returns the IDs of the
216217
// definitions the path may refer to.
217218
fn resolve_path(path: ~[ast::ident], data: @~[u8]) -> ~[ast::def_id] {
218-
fn eq_item(data: ~[u8], s: str) -> bool {
219-
ret str::eq(str::from_bytes(data), s);
219+
fn eq_item(data: &[u8], s: str) -> bool {
220+
// XXX: Use string equality.
221+
let data_len = data.len();
222+
let s_len = s.len();
223+
if data_len != s_len {
224+
ret false;
225+
}
226+
let mut i = 0;
227+
while i < data_len {
228+
if data[i] != s[i] {
229+
ret false;
230+
}
231+
i += 1;
232+
}
233+
ret true;
220234
}
221235
let s = ast_util::path_name_i(path);
222236
let md = ebml::doc(data);

0 commit comments

Comments
 (0)