remove remaining is_not_empty functions/methods

This commit is contained in:
Daniel Micay 2013-01-24 23:24:57 -05:00
parent ec3f6e1932
commit e4337a9def
18 changed files with 17 additions and 54 deletions

View File

@ -70,7 +70,7 @@ fn parse_config(args: ~[~str]) -> config {
getopts::optopt(~"logfile"),
getopts::optflag(~"jit")];
assert (vec::is_not_empty(args));
assert !args.is_empty();
let args_ = vec::tail(args);
let matches =
&match getopts::getopts(args_, opts) {

View File

@ -208,8 +208,6 @@ impl<T> DList<T> {
pure fn len(@self) -> uint { self.size }
/// Returns true if the list is empty. O(1).
pure fn is_empty(@self) -> bool { self.len() == 0 }
/// Returns true if the list is not empty. O(1).
pure fn is_not_empty(@self) -> bool { self.len() != 0 }
/// Add data to the head of the list. O(1).
fn push_head(@self, data: T) {
@ -648,8 +646,6 @@ mod tests {
let full1 = from_vec(~[1,2,3]);
assert empty.is_empty();
assert !full1.is_empty();
assert !empty.is_not_empty();
assert full1.is_not_empty();
}
#[test]
fn test_dlist_head_tail() {

View File

@ -1419,9 +1419,6 @@ pub pure fn is_ascii(s: &str) -> bool {
/// Returns true if the string has length 0
pub pure fn is_empty(s: &str) -> bool { len(s) == 0u }
/// Returns true if the string has length greater than 0
pub pure fn is_not_empty(s: &str) -> bool { !is_empty(s) }
/**
* Returns true if the string contains only whitespace
*
@ -2167,7 +2164,6 @@ pub trait StrSlice {
pure fn each_chari(it: fn(uint, char) -> bool);
pure fn ends_with(needle: &str) -> bool;
pure fn is_empty() -> bool;
pure fn is_not_empty() -> bool;
pure fn is_whitespace() -> bool;
pure fn is_alphanumeric() -> bool;
pure fn len() -> uint;
@ -2229,9 +2225,6 @@ impl &str: StrSlice {
/// Returns true if the string has length 0
#[inline]
pure fn is_empty() -> bool { is_empty(self) }
/// Returns true if the string has length greater than 0
#[inline]
pure fn is_not_empty() -> bool { is_not_empty(self) }
/**
* Returns true if the string contains only whitespace
*
@ -2739,12 +2732,6 @@ mod tests {
assert (!is_empty(~"a"));
}
#[test]
fn test_is_not_empty() {
assert (is_not_empty(~"a"));
assert (!is_not_empty(~""));
}
#[test]
fn test_replace() {
let a = ~"a";

View File

@ -84,7 +84,7 @@ terminate normally, but instead directly return from a function.
~~~
fn choose_weighted_item(v: &[Item]) -> Item {
assert v.is_not_empty();
assert !v.is_empty();
let mut so_far = 0u;
for v.each |item| {
so_far += item.weight;

View File

@ -49,11 +49,6 @@ pub pure fn is_empty<T>(v: &[const T]) -> bool {
as_const_buf(v, |_p, len| len == 0u)
}
/// Returns true if a vector contains some elements
pub pure fn is_not_empty<T>(v: &[const T]) -> bool {
as_const_buf(v, |_p, len| len > 0u)
}
/// Returns true if two vectors have the same length
pub pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool {
len(xs) == len(ys)
@ -2515,12 +2510,6 @@ mod tests {
assert (!is_empty(~[0]));
}
#[test]
fn test_is_not_empty() {
assert (is_not_empty(~[0]));
assert (!is_not_empty::<int>(~[]));
}
#[test]
fn test_len_divzero() {
type Z = [i8 * 0];

View File

@ -167,7 +167,7 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
path.push_all(vec::view(split2, start_idx, len2 - 1));
if vec::is_not_empty(path) {
if !path.is_empty() {
return Path("").push_many(path);
} else {
return Path(".");

View File

@ -1018,8 +1018,8 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: &crate) -> ~[attribute] {
fn synthesize_link_attr(ecx: @encode_ctxt, +items: ~[@meta_item]) ->
attribute {
assert ecx.link_meta.name.is_not_empty();
assert ecx.link_meta.vers.is_not_empty();
assert !ecx.link_meta.name.is_empty();
assert !ecx.link_meta.vers.is_empty();
let name_item =
attr::mk_name_value_item_str(~"name",

View File

@ -179,7 +179,7 @@ fn crate_matches(crate_data: @~[u8], +metas: ~[@ast::meta_item],
hash: ~str) -> bool {
let attrs = decoder::get_crate_attributes(crate_data);
let linkage_metas = attr::find_linkage_metas(attrs);
if hash.is_not_empty() {
if !hash.is_empty() {
let chash = decoder::get_crate_hash(crate_data);
if chash != hash { return false; }
}

View File

@ -820,7 +820,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
fn is_camel_case(cx: ty::ctxt, ident: ast::ident) -> bool {
let ident = cx.sess.str_of(ident);
assert ident.is_not_empty();
assert !ident.is_empty();
let ident = ident_without_trailing_underscores(ident);
let ident = ident_without_leading_underscores(ident);
char::is_uppercase(str::char_at(ident, 0)) &&

View File

@ -127,7 +127,7 @@ pub fn parse_hidden(+attrs: ~[ast::attribute]) -> bool {
match attr::get_meta_item_list(*meta) {
Some(metas) => {
let hiddens = attr::find_meta_items_by_name(metas, ~"hidden");
vec::is_not_empty(hiddens)
!hiddens.is_empty()
}
None => false
}

View File

@ -143,7 +143,7 @@ fn parse_desc(desc: ~str) -> Option<~str> {
fn first_sentence(s: ~str) -> Option<~str> {
let paras = paragraphs(s);
if vec::is_not_empty(paras) {
if !paras.is_empty() {
let first_para = vec::head(paras);
Some(str::replace(first_sentence_(first_para), ~"\n", ~" "))
} else {
@ -193,7 +193,7 @@ fn paragraphs(s: ~str) -> ~[~str] {
whitespace_lines += 1;
} else {
if whitespace_lines > 0 {
if str::is_not_empty(accum) {
if !accum.is_empty() {
res += ~[accum];
accum = ~"";
}
@ -211,7 +211,7 @@ fn paragraphs(s: ~str) -> ~[~str] {
res
};
if str::is_not_empty(accum) {
if !accum.is_empty() {
paras + ~[accum]
} else {
paras

View File

@ -78,7 +78,7 @@ fn unindent(s: ~str) -> ~str {
}
};
if vec::is_not_empty(lines) {
if !lines.is_empty() {
let unindented = ~[str::trim(vec::head(lines))]
+ do par::map(vec::tail(lines)) |line| {
if str::is_whitespace(*line) {

View File

@ -83,11 +83,6 @@ pub pure fn is_empty<T: Copy>(ls: @List<T>) -> bool {
}
}
/// Returns true if the list is not empty
pub pure fn is_not_empty<T: Copy>(ls: @List<T>) -> bool {
return !is_empty(ls);
}
/// Returns the length of a list
pub pure fn len<T>(ls: @List<T>) -> uint {
let mut count = 0u;
@ -177,10 +172,6 @@ mod tests {
assert is_empty(empty);
assert !is_empty(full1);
assert !is_empty(full2);
assert !is_not_empty(empty);
assert is_not_empty(full1);
assert is_not_empty(full2);
}
#[test]

View File

@ -245,7 +245,7 @@ fn contains_name(metas: &[@ast::meta_item], name: &str) -> bool {
}
fn attrs_contains_name(attrs: &[ast::attribute], name: &str) -> bool {
vec::is_not_empty(find_attrs_by_name(attrs, name))
!find_attrs_by_name(attrs, name).is_empty()
}
fn first_attr_value_str_by_name(attrs: ~[ast::attribute], name: ~str)

View File

@ -192,7 +192,7 @@ fn diagnosticcolor(lvl: level) -> u8 {
fn print_diagnostic(topic: ~str, lvl: level, msg: &str) {
let use_color = term::color_supported() &&
io::stderr().get_type() == io::Screen;
if str::is_not_empty(topic) {
if !topic.is_empty() {
io::stderr().write_str(fmt!("%s ", topic));
}
if use_color {

View File

@ -2237,7 +2237,7 @@ impl Parser {
fn check_expected_item(p: Parser, current_attrs: ~[attribute]) {
// If we have attributes then we should have an item
if vec::is_not_empty(current_attrs) {
if !current_attrs.is_empty() {
p.fatal(~"expected item after attrs");
}
}

View File

@ -23,7 +23,7 @@ pure fn pure_length<T: Copy>(ls: @List<T>) -> uint { pure_length_go(ls, 0u) }
pure fn nonempty_list<T: Copy>(ls: @List<T>) -> bool { pure_length(ls) > 0u }
fn safe_head<T: Copy>(ls: @List<T>) -> T {
assert is_not_empty(ls);
assert !is_empty(ls);
return head(ls);
}

View File

@ -10,7 +10,7 @@
// In this case, the code should compile and should
// succeed at runtime
use vec::{head, is_not_empty, last, same_length, zip};
use vec::{head, last, same_length, zip};
fn enum_chars(start: u8, end: u8) -> ~[char] {
assert start < end;