rustc: Remove a few allocations from metadata. Shaves a few milliseconds off compilation of hello world.
This commit is contained in:
parent
69daeffddb
commit
9ea6b3a32e
@ -521,7 +521,7 @@ fn u64_to_be_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T {
|
||||
}
|
||||
}
|
||||
|
||||
fn u64_from_be_bytes(data: ~[u8], start: uint, size: uint) -> u64 {
|
||||
fn u64_from_be_bytes(data: &[const u8], start: uint, size: uint) -> u64 {
|
||||
let mut sz = size;
|
||||
assert (sz <= 8u);
|
||||
let mut val = 0_u64;
|
||||
|
@ -121,7 +121,7 @@ impl T: iter::TimesIx {
|
||||
*
|
||||
* `buf` must not be empty
|
||||
*/
|
||||
fn parse_buf(buf: ~[u8], radix: uint) -> option<T> {
|
||||
fn parse_buf(buf: &[const u8], radix: uint) -> option<T> {
|
||||
if vec::len(buf) == 0u { return none; }
|
||||
let mut i = vec::len(buf) - 1u;
|
||||
let mut power = 1u as T;
|
||||
|
@ -72,7 +72,7 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
|
||||
let belt = tag_index_buckets_bucket_elt;
|
||||
for ebml::tagged_docs(bucket, belt) |elt| {
|
||||
let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint;
|
||||
if eq_fn(vec::slice(*elt.data, elt.start + 4u, elt.end)) {
|
||||
if eq_fn(vec::view(*elt.data, elt.start + 4u, elt.end)) {
|
||||
return some(ebml::doc_at(d.data, pos).doc);
|
||||
}
|
||||
};
|
||||
@ -81,7 +81,7 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
|
||||
|
||||
fn maybe_find_item(item_id: int, items: ebml::doc) -> option<ebml::doc> {
|
||||
fn eq_item(bytes: &[u8], item_id: int) -> bool {
|
||||
return io::u64_from_be_bytes(vec::slice(bytes, 0u, 4u), 0u, 4u) as int
|
||||
return io::u64_from_be_bytes(vec::view(bytes, 0u, 4u), 0u, 4u) as int
|
||||
== item_id;
|
||||
}
|
||||
lookup_hash(items,
|
||||
|
@ -391,8 +391,9 @@ fn parse_def_id(buf: &[u8]) -> ast::def_id {
|
||||
error!{"didn't find ':' when parsing def id"};
|
||||
fail;
|
||||
}
|
||||
let crate_part = vec::slice(buf, 0u, colon_idx);
|
||||
let def_part = vec::slice(buf, colon_idx + 1u, len);
|
||||
|
||||
let crate_part = vec::view(buf, 0u, colon_idx);
|
||||
let def_part = vec::view(buf, colon_idx + 1u, len);
|
||||
|
||||
let crate_num = match uint::parse_buf(crate_part, 10u) {
|
||||
some(cn) => cn as int,
|
||||
|
Loading…
x
Reference in New Issue
Block a user