Skip to content

Commit

Permalink
remove deprecated vec::{is_empty, len} functions
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Jun 9, 2013
1 parent 470bf0d commit de36715
Show file tree
Hide file tree
Showing 38 changed files with 100 additions and 104 deletions.
2 changes: 1 addition & 1 deletion doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2046,7 +2046,7 @@ trait Seq<T> {
}
impl<T> Seq<T> for ~[T] {
fn len(&self) -> uint { vec::len(*self) }
fn len(&self) -> uint { self.len() }
fn iter(&self, b: &fn(v: &T)) {
for vec::each(*self) |elt| { b(elt); }
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn parse_config(args: ~[~str]) -> config {
mode: str_mode(getopts::opt_str(matches, "mode")),
run_ignored: getopts::opt_present(matches, "ignored"),
filter:
if vec::len(matches.free) > 0u {
if !matches.free.is_empty() {
option::Some(copy matches.free[0])
} else { option::None },
logfile: getopts::opt_maybe_str(matches, "logfile").map(|s| Path(*s)),
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
fn check_error_patterns(props: &TestProps,
testfile: &Path,
ProcRes: &ProcRes) {
if vec::is_empty(props.error_patterns) {
if props.error_patterns.is_empty() {
fatal(~"no error pattern specified in " + testfile.to_str());
}
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub mod reader {
}

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

pub fn doc_at(data: @~[u8], start: uint) -> TaggedDoc {
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/getopts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ pub fn opt_strs(mm: &Matches, nm: &str) -> ~[~str] {
/// Returns the string argument supplied to a matching option or none
pub fn opt_maybe_str(mm: &Matches, nm: &str) -> Option<~str> {
let vals = opt_vals(mm, nm);
if vec::len::<Optval>(vals) == 0u { return None::<~str>; }
if vals.is_empty() { return None::<~str>; }
return match vals[0] {
Val(ref s) => Some(copy *s),
_ => None
Expand All @@ -444,7 +444,7 @@ pub fn opt_maybe_str(mm: &Matches, nm: &str) -> Option<~str> {
*/
pub fn opt_default(mm: &Matches, nm: &str, def: &str) -> Option<~str> {
let vals = opt_vals(mm, nm);
if vec::len::<Optval>(vals) == 0u { return None::<~str>; }
if vals.is_empty() { return None::<~str>; }
return match vals[0] { Val(ref s) => Some::<~str>(copy *s),
_ => Some::<~str>(str::to_owned(def)) }
}
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub fn sha1() -> @Sha1 {
* can be assumed that the message digest has been computed.
*/
fn pad_msg(st: &mut Sha1State) {
assert_eq!(vec::len((*st).msg_block), msg_block_len);
assert_eq!((*st).msg_block.len(), msg_block_len);

/*
* Check to see if the current message block is too small to hold
Expand Down Expand Up @@ -368,8 +368,8 @@ mod tests {
];
let tests = fips_180_1_tests + wikipedia_tests;
fn check_vec_eq(v0: ~[u8], v1: ~[u8]) {
assert_eq!(vec::len::<u8>(v0), vec::len::<u8>(v1));
let len = vec::len::<u8>(v0);
assert_eq!(v0.len(), v1.len());
let len = v0.len();
let mut i = 0u;
while i < len {
let a = v0[i];
Expand Down
24 changes: 12 additions & 12 deletions src/libextra/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use core::prelude::*;
use core::cmp::{Eq, Ord};
use core::uint;
use core::util::swap;
use core::vec::len;
use core::vec;

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

return merge_sort_(v, (0u, len(v)), le);
return merge_sort_(v, (0u, v.len()), le);

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

fn merge<T:Copy>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
let mut rs = vec::with_capacity(len(a) + len(b));
let a_len = len(a);
let mut rs = vec::with_capacity(a.len() + b.len());
let a_len = a.len();
let mut a_ix = 0;
let b_len = len(b);
let b_len = b.len();
let mut b_ix = 0;
while a_ix < a_len && b_ix < b_len {
if le(&a[a_ix], &b[b_ix]) {
Expand Down Expand Up @@ -100,8 +99,9 @@ fn qsort<T>(arr: &mut [T], left: uint,
* This is an unstable sort.
*/
pub fn quick_sort<T>(arr: &mut [T], compare_func: Le<T>) {
if len::<T>(arr) == 0u { return; }
qsort::<T>(arr, 0u, len::<T>(arr) - 1u, compare_func);
let len = arr.len();
if len == 0u { return; }
qsort::<T>(arr, 0u, len - 1u, compare_func);
}

fn qsort3<T:Copy + Ord + Eq>(arr: &mut [T], left: int, right: int) {
Expand Down Expand Up @@ -138,7 +138,7 @@ fn qsort3<T:Copy + Ord + Eq>(arr: &mut [T], left: int, right: int) {
vec::swap(arr, k as uint, j as uint);
k += 1;
j -= 1;
if k == len::<T>(arr) as int { break; }
if k == arr.len() as int { break; }
}
k = right - 1;
while k > q {
Expand Down Expand Up @@ -754,7 +754,7 @@ mod test_qsort3 {
use core::vec;

fn check_sort(v1: &mut [int], v2: &mut [int]) {
let len = vec::len::<int>(v1);
let len = v1.len();
quick_sort3::<int>(v1);
let mut i = 0;
while i < len {
Expand Down Expand Up @@ -799,7 +799,7 @@ mod test_qsort {
use core::vec;

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

fn check_sort(v1: &[int], v2: &[int]) {
let len = vec::len::<int>(v1);
let len = v1.len();
pub fn le(a: &int, b: &int) -> bool { *a <= *b }
let f = le;
let v3 = merge_sort::<int>(v1, f);
Expand Down Expand Up @@ -951,7 +951,7 @@ mod test_tim_sort {
}

fn check_sort(v1: &mut [int], v2: &mut [int]) {
let len = vec::len::<int>(v1);
let len = v1.len();
tim_sort::<int>(v1);
let mut i = 0u;
while i < len {
Expand Down
2 changes: 1 addition & 1 deletion src/libextra/uv_ll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ pub unsafe fn accept(server: *libc::c_void, client: *libc::c_void)
pub unsafe fn write<T>(req: *uv_write_t, stream: *T,
buf_in: *~[uv_buf_t], cb: *u8) -> libc::c_int {
let buf_ptr = vec::raw::to_ptr(*buf_in);
let buf_cnt = vec::len(*buf_in) as i32;
let buf_cnt = (*buf_in).len() as i32;
return rust_uv_write(req as *libc::c_void,
stream as *libc::c_void,
buf_ptr, buf_cnt, cb);
Expand Down
4 changes: 2 additions & 2 deletions src/libfuzzer/fuzzer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
}

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

pub fn main() {
let args = os::args();
if vec::len(args) != 2u {
if args.len() != 2u {
error!("usage: %s <testdir>", args[0]);
return;
}
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ fn is_test_fn(cx: @mut TestCtxt, i: @ast::item) -> bool {
}

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

fn has_test_signature(i: @ast::item) -> bool {
match i.node {
Expand Down Expand Up @@ -242,7 +241,7 @@ fn is_ignored(cx: @mut TestCtxt, i: @ast::item) -> bool {
}

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

fn add_test_module(cx: &TestCtxt, m: &ast::_mod) -> ast::_mod {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn get_metadata_section(os: os,
let mut found = None;
unsafe {
let cvbuf: *u8 = cast::transmute(cbuf);
let vlen = vec::len(encoder::metadata_encoding_version);
let vlen = encoder::metadata_encoding_version.len();
debug!("checking %u bytes of metadata-version stamp",
vlen);
let minsz = uint::min(vlen, csz);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ pub fn check_fn(cx: @MatchCheckCtxt,
pub fn is_refutable(cx: @MatchCheckCtxt, pat: &pat) -> bool {
match cx.tcx.def_map.find(&pat.id) {
Some(&def_variant(enum_id, _)) => {
if vec::len(*ty::enum_variants(cx.tcx, enum_id)) != 1u {
if ty::enum_variants(cx.tcx, enum_id).len() != 1u {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/freevars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info {
}

pub fn has_freevars(tcx: ty::ctxt, fid: ast::node_id) -> bool {
return vec::len(*get_freevars(tcx, fid)) != 0u;
!get_freevars(tcx, fid).is_empty()
}
2 changes: 1 addition & 1 deletion src/librustc/middle/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ fn is_nullary_variant(cx: Context, ex: @expr) -> bool {
expr_path(_) => {
match cx.tcx.def_map.get_copy(&ex.id) {
def_variant(edid, vdid) => {
vec::len(ty::enum_variant_with_id(cx.tcx, edid, vdid).args) == 0u
ty::enum_variant_with_id(cx.tcx, edid, vdid).args.is_empty()
}
_ => false
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/trans/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ pub fn count_insn(cx: block, category: &str) {

// Pass 1: scan table mapping str -> rightmost pos.
let mut mm = HashMap::new();
let len = vec::len(*v);
let len = v.len();
let mut i = 0u;
while i < len {
mm.insert(copy v[i], i);
i += 1u;
}


// Pass 2: concat strings for each elt, skipping
// forwards over any cycles by advancing to rightmost
// occurrence of each element in path.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2373,7 +2373,7 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
ty_enum(did, ref substs) => {
seen.push(did);
let vs = enum_variants(cx, did);
let r = vec::len(*vs) > 0u && do vs.iter().all |variant| {
let r = !vs.is_empty() && do vs.iter().all |variant| {
do variant.args.iter().any |aty| {
let sty = subst(cx, substs, *aty);
type_requires(cx, seen, r_ty, sty)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/typeck/infer/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ impl ResolveState {
// n.b. This is a hokey mess because the current fold doesn't
// allow us to pass back errors in any useful way.

assert!(vec::is_empty(self.v_seen));
assert!(self.v_seen.is_empty());
let rty = indent(|| self.resolve_type(typ) );
assert!(vec::is_empty(self.v_seen));
assert!(self.v_seen.is_empty());
match self.err {
None => {
debug!("Resolved to %s + %s (modes=%x)",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/rustc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
version(*binary);
return;
}
let input = match vec::len(matches.free) {
let input = match matches.free.len() {
0u => early_error(demitter, ~"no input filename given"),
1u => {
let ifile = /*bad*/copy matches.free[0];
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/astsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn should_prune_unconfigured_items() {
let source = ~"#[cfg(shut_up_and_leave_me_alone)]fn a() { }";
do from_str(source) |srv| {
do exec(srv) |ctxt| {
assert!(vec::is_empty(ctxt.ast.node.module.items));
assert!(ctxt.ast.node.module.items.is_empty());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ mod test {
#[test]
fn extract_empty_crate() {
let doc = mk_doc(~"");
assert!(vec::is_empty(doc.cratemod().mods()));
assert!(vec::is_empty(doc.cratemod().fns()));
assert!(doc.cratemod().mods().is_empty());
assert!(doc.cratemod().fns().is_empty());
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/markdown_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ fn item_header_lvl(doc: &doc::ItemTag) -> Hlvl {
}

fn write_index(ctxt: &Ctxt, index: &doc::Index) {
if vec::is_empty(index.entries) {
if index.entries.is_empty() {
return;
}

Expand Down Expand Up @@ -437,7 +437,7 @@ fn write_variants(
ctxt: &Ctxt,
docs: &[doc::VariantDoc]
) {
if vec::is_empty(docs) {
if docs.is_empty() {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/page_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,6 @@ mod test {
#[test]
fn should_remove_mods_from_containing_mods() {
let doc = mk_doc(~"mod a { }");
assert!(vec::is_empty(doc.cratemod().mods()));
assert!(doc.cratemod().mods().is_empty());
}
}
2 changes: 1 addition & 1 deletion src/librustdoc/prune_hidden_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ mod test {
use core::vec;

let doc = mk_doc(~"#[doc(hidden)] mod a { }");
assert!(vec::is_empty(doc.cratemod().mods()))
assert!(doc.cratemod().mods().is_empty())
}
}
2 changes: 1 addition & 1 deletion src/librustdoc/prune_private_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ mod test {
#[test]
fn should_prune_items_without_pub_modifier() {
let doc = mk_doc(~"mod a { }");
assert!(vec::is_empty(doc.cratemod().mods()));
assert!(doc.cratemod().mods().is_empty());
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/sectionalize_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ mod test {
Body\"]\
mod a {
}");
assert!(vec::is_empty(doc.cratemod().mods()[0].item.sections));
assert!(doc.cratemod().mods()[0].item.sections.is_empty());
}

#[test]
Expand Down
7 changes: 4 additions & 3 deletions src/libstd/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use option::{None, Option, Some};
use old_iter::BaseIter;
use vec;
use vec::OwnedVector;
use container::Container;

/// The result type
#[deriving(Clone, Eq)]
Expand Down Expand Up @@ -301,7 +302,7 @@ impl<T, E: Copy> Result<T, E> {
pub fn map_vec<T,U:Copy,V:Copy>(
ts: &[T], op: &fn(&T) -> Result<V,U>) -> Result<~[V],U> {

let mut vs: ~[V] = vec::with_capacity(vec::len(ts));
let mut vs: ~[V] = vec::with_capacity(ts.len());
for ts.each |t| {
match op(t) {
Ok(v) => vs.push(v),
Expand Down Expand Up @@ -339,7 +340,7 @@ pub fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
op: &fn(&S,&T) -> Result<V,U>) -> Result<~[V],U> {

assert!(vec::same_length(ss, ts));
let n = vec::len(ts);
let n = ts.len();
let mut vs = vec::with_capacity(n);
let mut i = 0u;
while i < n {
Expand All @@ -362,7 +363,7 @@ pub fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T],
op: &fn(&S,&T) -> Result<(),U>) -> Result<(),U> {

assert!(vec::same_length(ss, ts));
let n = vec::len(ts);
let n = ts.len();
let mut i = 0u;
while i < n {
match op(&ss[i],&ts[i]) {
Expand Down
Loading

5 comments on commit de36715

@bors
Copy link
Contributor

@bors bors commented on de36715 Jun 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on de36715 Jun 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging thestinger/rust/vec = de36715 into auto

@bors
Copy link
Contributor

@bors bors commented on de36715 Jun 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thestinger/rust/vec = de36715 merged ok, testing candidate = 88c318d

@bors
Copy link
Contributor

@bors bors commented on de36715 Jun 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on de36715 Jun 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 88c318d

Please sign in to comment.