Skip to content

Commit 88c318d

Browse files
committed
auto merge of #7023 : thestinger/rust/vec, r=brson
2 parents 1f0c05f + de36715 commit 88c318d

38 files changed

+100
-104
lines changed

doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2046,7 +2046,7 @@ trait Seq<T> {
20462046
}
20472047
20482048
impl<T> Seq<T> for ~[T] {
2049-
fn len(&self) -> uint { vec::len(*self) }
2049+
fn len(&self) -> uint { self.len() }
20502050
fn iter(&self, b: &fn(v: &T)) {
20512051
for vec::each(*self) |elt| { b(elt); }
20522052
}

src/compiletest/compiletest.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn parse_config(args: ~[~str]) -> config {
9797
mode: str_mode(getopts::opt_str(matches, "mode")),
9898
run_ignored: getopts::opt_present(matches, "ignored"),
9999
filter:
100-
if vec::len(matches.free) > 0u {
100+
if !matches.free.is_empty() {
101101
option::Some(copy matches.free[0])
102102
} else { option::None },
103103
logfile: getopts::opt_maybe_str(matches, "logfile").map(|s| Path(*s)),

src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
297297
fn check_error_patterns(props: &TestProps,
298298
testfile: &Path,
299299
ProcRes: &ProcRes) {
300-
if vec::is_empty(props.error_patterns) {
300+
if props.error_patterns.is_empty() {
301301
fatal(~"no error pattern specified in " + testfile.to_str());
302302
}
303303

src/libextra/ebml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub mod reader {
179179
}
180180

181181
pub fn Doc(data: @~[u8]) -> Doc {
182-
Doc { data: data, start: 0u, end: vec::len::<u8>(*data) }
182+
Doc { data: data, start: 0u, end: data.len() }
183183
}
184184

185185
pub fn doc_at(data: @~[u8], start: uint) -> TaggedDoc {

src/libextra/getopts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ pub fn opt_strs(mm: &Matches, nm: &str) -> ~[~str] {
427427
/// Returns the string argument supplied to a matching option or none
428428
pub fn opt_maybe_str(mm: &Matches, nm: &str) -> Option<~str> {
429429
let vals = opt_vals(mm, nm);
430-
if vec::len::<Optval>(vals) == 0u { return None::<~str>; }
430+
if vals.is_empty() { return None::<~str>; }
431431
return match vals[0] {
432432
Val(ref s) => Some(copy *s),
433433
_ => None
@@ -444,7 +444,7 @@ pub fn opt_maybe_str(mm: &Matches, nm: &str) -> Option<~str> {
444444
*/
445445
pub fn opt_default(mm: &Matches, nm: &str, def: &str) -> Option<~str> {
446446
let vals = opt_vals(mm, nm);
447-
if vec::len::<Optval>(vals) == 0u { return None::<~str>; }
447+
if vals.is_empty() { return None::<~str>; }
448448
return match vals[0] { Val(ref s) => Some::<~str>(copy *s),
449449
_ => Some::<~str>(str::to_owned(def)) }
450450
}

src/libextra/sha1.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pub fn sha1() -> @Sha1 {
195195
* can be assumed that the message digest has been computed.
196196
*/
197197
fn pad_msg(st: &mut Sha1State) {
198-
assert_eq!(vec::len((*st).msg_block), msg_block_len);
198+
assert_eq!((*st).msg_block.len(), msg_block_len);
199199

200200
/*
201201
* Check to see if the current message block is too small to hold
@@ -368,8 +368,8 @@ mod tests {
368368
];
369369
let tests = fips_180_1_tests + wikipedia_tests;
370370
fn check_vec_eq(v0: ~[u8], v1: ~[u8]) {
371-
assert_eq!(vec::len::<u8>(v0), vec::len::<u8>(v1));
372-
let len = vec::len::<u8>(v0);
371+
assert_eq!(v0.len(), v1.len());
372+
let len = v0.len();
373373
let mut i = 0u;
374374
while i < len {
375375
let a = v0[i];

src/libextra/sort.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use core::prelude::*;
1515
use core::cmp::{Eq, Ord};
1616
use core::uint;
1717
use core::util::swap;
18-
use core::vec::len;
1918
use core::vec;
2019

2120
type Le<'self, T> = &'self fn(v1: &T, v2: &T) -> bool;
@@ -29,7 +28,7 @@ type Le<'self, T> = &'self fn(v1: &T, v2: &T) -> bool;
2928
pub fn merge_sort<T:Copy>(v: &[T], le: Le<T>) -> ~[T] {
3029
type Slice = (uint, uint);
3130

32-
return merge_sort_(v, (0u, len(v)), le);
31+
return merge_sort_(v, (0u, v.len()), le);
3332

3433
fn merge_sort_<T:Copy>(v: &[T], slice: Slice, le: Le<T>)
3534
-> ~[T] {
@@ -47,10 +46,10 @@ pub fn merge_sort<T:Copy>(v: &[T], le: Le<T>) -> ~[T] {
4746
}
4847

4948
fn merge<T:Copy>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
50-
let mut rs = vec::with_capacity(len(a) + len(b));
51-
let a_len = len(a);
49+
let mut rs = vec::with_capacity(a.len() + b.len());
50+
let a_len = a.len();
5251
let mut a_ix = 0;
53-
let b_len = len(b);
52+
let b_len = b.len();
5453
let mut b_ix = 0;
5554
while a_ix < a_len && b_ix < b_len {
5655
if le(&a[a_ix], &b[b_ix]) {
@@ -100,8 +99,9 @@ fn qsort<T>(arr: &mut [T], left: uint,
10099
* This is an unstable sort.
101100
*/
102101
pub fn quick_sort<T>(arr: &mut [T], compare_func: Le<T>) {
103-
if len::<T>(arr) == 0u { return; }
104-
qsort::<T>(arr, 0u, len::<T>(arr) - 1u, compare_func);
102+
let len = arr.len();
103+
if len == 0u { return; }
104+
qsort::<T>(arr, 0u, len - 1u, compare_func);
105105
}
106106

107107
fn qsort3<T:Copy + Ord + Eq>(arr: &mut [T], left: int, right: int) {
@@ -138,7 +138,7 @@ fn qsort3<T:Copy + Ord + Eq>(arr: &mut [T], left: int, right: int) {
138138
vec::swap(arr, k as uint, j as uint);
139139
k += 1;
140140
j -= 1;
141-
if k == len::<T>(arr) as int { break; }
141+
if k == arr.len() as int { break; }
142142
}
143143
k = right - 1;
144144
while k > q {
@@ -754,7 +754,7 @@ mod test_qsort3 {
754754
use core::vec;
755755

756756
fn check_sort(v1: &mut [int], v2: &mut [int]) {
757-
let len = vec::len::<int>(v1);
757+
let len = v1.len();
758758
quick_sort3::<int>(v1);
759759
let mut i = 0;
760760
while i < len {
@@ -799,7 +799,7 @@ mod test_qsort {
799799
use core::vec;
800800

801801
fn check_sort(v1: &mut [int], v2: &mut [int]) {
802-
let len = vec::len::<int>(v1);
802+
let len = v1.len();
803803
fn leual(a: &int, b: &int) -> bool { *a <= *b }
804804
quick_sort::<int>(v1, leual);
805805
let mut i = 0u;
@@ -864,7 +864,7 @@ mod tests {
864864
use core::vec;
865865

866866
fn check_sort(v1: &[int], v2: &[int]) {
867-
let len = vec::len::<int>(v1);
867+
let len = v1.len();
868868
pub fn le(a: &int, b: &int) -> bool { *a <= *b }
869869
let f = le;
870870
let v3 = merge_sort::<int>(v1, f);
@@ -951,7 +951,7 @@ mod test_tim_sort {
951951
}
952952

953953
fn check_sort(v1: &mut [int], v2: &mut [int]) {
954-
let len = vec::len::<int>(v1);
954+
let len = v1.len();
955955
tim_sort::<int>(v1);
956956
let mut i = 0u;
957957
while i < len {

src/libextra/uv_ll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ pub unsafe fn accept(server: *libc::c_void, client: *libc::c_void)
988988
pub unsafe fn write<T>(req: *uv_write_t, stream: *T,
989989
buf_in: *~[uv_buf_t], cb: *u8) -> libc::c_int {
990990
let buf_ptr = vec::raw::to_ptr(*buf_in);
991-
let buf_cnt = vec::len(*buf_in) as i32;
991+
let buf_cnt = (*buf_in).len() as i32;
992992
return rust_uv_write(req as *libc::c_void,
993993
stream as *libc::c_void,
994994
buf_ptr, buf_cnt, cb);

src/libfuzzer/fuzzer.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
624624
}
625625

626626
pub fn check_convergence(files: &[Path]) {
627-
error!("pp convergence tests: %u files", vec::len(files));
627+
error!("pp convergence tests: %u files", files.len());
628628
for files.each |file| {
629629
if !file_might_not_converge(file) {
630630
let s = @result::get(&io::read_whole_file_str(file));
@@ -689,7 +689,7 @@ pub fn check_variants(files: &[Path], cx: Context) {
689689

690690
pub fn main() {
691691
let args = os::args();
692-
if vec::len(args) != 2u {
692+
if args.len() != 2u {
693693
error!("usage: %s <testdir>", args[0]);
694694
return;
695695
}

src/librustc/front/test.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ fn is_test_fn(cx: @mut TestCtxt, i: @ast::item) -> bool {
203203
}
204204

205205
fn is_bench_fn(i: @ast::item) -> bool {
206-
let has_bench_attr =
207-
vec::len(attr::find_attrs_by_name(i.attrs, "bench")) > 0u;
206+
let has_bench_attr = !attr::find_attrs_by_name(i.attrs, "bench").is_empty();
208207

209208
fn has_test_signature(i: @ast::item) -> bool {
210209
match i.node {
@@ -242,7 +241,7 @@ fn is_ignored(cx: @mut TestCtxt, i: @ast::item) -> bool {
242241
}
243242

244243
fn should_fail(i: @ast::item) -> bool {
245-
vec::len(attr::find_attrs_by_name(i.attrs, "should_fail")) > 0u
244+
!attr::find_attrs_by_name(i.attrs, "should_fail").is_empty()
246245
}
247246

248247
fn add_test_module(cx: &TestCtxt, m: &ast::_mod) -> ast::_mod {

0 commit comments

Comments
 (0)