Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces the free-standing functions in f32, &c. #7090

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/libextra/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ use core::uint;
use core::vec;
use core::unstable::intrinsics;

use core::num;

pub mod rustrt {
use core::libc::size_t;
use core::sys::TypeDesc;
Expand Down Expand Up @@ -171,7 +173,7 @@ impl Arena {
fn alloc_pod_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
// Allocate a new chunk.
let chunk_size = at_vec::capacity(self.pod_head.data);
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
let new_min_chunk_size = num::max(n_bytes, chunk_size);
self.chunks = @mut MutCons(copy self.pod_head, self.chunks);
self.pod_head =
chunk(uint::next_power_of_two(new_min_chunk_size + 1u), true);
Expand Down Expand Up @@ -215,7 +217,7 @@ impl Arena {
-> (*u8, *u8) {
// Allocate a new chunk.
let chunk_size = at_vec::capacity(self.head.data);
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
let new_min_chunk_size = num::max(n_bytes, chunk_size);
self.chunks = @mut MutCons(copy self.head, self.chunks);
self.head =
chunk(uint::next_power_of_two(new_min_chunk_size + 1u), false);
Expand Down
7 changes: 4 additions & 3 deletions src/libextra/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use core::prelude::*;

use core::cmp;
use core::num;
use core::ops;
use core::uint;
use core::vec;
Expand Down Expand Up @@ -725,7 +726,7 @@ impl Set<uint> for BitvSet {
}
let nbits = self.capacity();
if value >= nbits {
let newsize = uint::max(value, nbits * 2) / uint::bits + 1;
let newsize = num::max(value, nbits * 2) / uint::bits + 1;
assert!(newsize > self.bitv.storage.len());
self.bitv.storage.grow(newsize, &0);
}
Expand Down Expand Up @@ -824,7 +825,7 @@ impl BitvSet {
/// and w1/w2 are the words coming from the two vectors self, other.
fn each_common(&self, other: &BitvSet,
f: &fn(uint, uint, uint) -> bool) -> bool {
let min = uint::min(self.bitv.storage.len(),
let min = num::min(self.bitv.storage.len(),
other.bitv.storage.len());
self.bitv.storage.slice(0, min).eachi(|i, &w| {
f(i * uint::bits, w, other.bitv.storage[i])
Expand All @@ -842,7 +843,7 @@ impl BitvSet {
f: &fn(bool, uint, uint) -> bool) -> bool {
let len1 = self.bitv.storage.len();
let len2 = other.bitv.storage.len();
let min = uint::min(len1, len2);
let min = num::min(len1, len2);

/* only one of these loops will execute and that's the point */
for self.bitv.storage.slice(min, len1).eachi |i, &w| {
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/net_tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use core::io;
use core::libc::size_t;
use core::libc;
use core::comm::{stream, Port, SharedChan};
use core::num;
use core::ptr;
use core::result::{Result};
use core::result;
use core::uint;
use core::vec;

pub mod rustrt {
Expand Down Expand Up @@ -884,7 +884,7 @@ impl io::Reader for TcpSocketBuf {
let needed = len - count;
if nbuffered > 0 {
unsafe {
let ncopy = uint::min(nbuffered, needed);
let ncopy = num::min(nbuffered, needed);
let dst = ptr::mut_offset(
vec::raw::to_mut_ptr(buf), count);
let src = ptr::offset(
Expand Down
18 changes: 9 additions & 9 deletions src/libextra/num/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use core::prelude::*;
use core::iterator::IteratorUtil;
use core::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
use core::int;
use core::num::{IntConvertible, Zero, One, ToStrRadix, FromStrRadix, Orderable};
use core::num::{IntConvertible, Zero, One, ToStrRadix, FromStrRadix, Orderable, min, max};
use core::str;
use core::uint;
use core::vec;
Expand Down Expand Up @@ -205,7 +205,7 @@ impl Unsigned for BigUint {}
impl Add<BigUint, BigUint> for BigUint {

fn add(&self, other: &BigUint) -> BigUint {
let new_len = uint::max(self.data.len(), other.data.len());
let new_len = max(self.data.len(), other.data.len());

let mut carry = 0;
let sum = do vec::from_fn(new_len) |i| {
Expand All @@ -225,7 +225,7 @@ impl Add<BigUint, BigUint> for BigUint {
impl Sub<BigUint, BigUint> for BigUint {

fn sub(&self, other: &BigUint) -> BigUint {
let new_len = uint::max(self.data.len(), other.data.len());
let new_len = max(self.data.len(), other.data.len());

let mut borrow = 0;
let diff = do vec::from_fn(new_len) |i| {
Expand Down Expand Up @@ -261,7 +261,7 @@ impl Mul<BigUint, BigUint> for BigUint {
// = a1*b1 * base^2 +
// (a1*b1 + a0*b0 - (a1-b0)*(b1-a0)) * base +
// a0*b0
let half_len = uint::max(s_len, o_len) / 2;
let half_len = max(s_len, o_len) / 2;
let (sHi, sLo) = cut_at(self, half_len);
let (oHi, oLo) = cut_at(other, half_len);

Expand Down Expand Up @@ -298,7 +298,7 @@ impl Mul<BigUint, BigUint> for BigUint {


fn cut_at(a: &BigUint, n: uint) -> (BigUint, BigUint) {
let mid = uint::min(a.data.len(), n);
let mid = min(a.data.len(), n);
return (BigUint::from_slice(vec::slice(a.data, mid,
a.data.len())),
BigUint::from_slice(vec::slice(a.data, 0, mid)));
Expand Down Expand Up @@ -482,7 +482,7 @@ impl Integer for BigUint {
impl IntConvertible for BigUint {

fn to_int(&self) -> int {
uint::min(self.to_uint(), int::max_value as uint) as int
min(self.to_uint(), int::max_value as uint) as int
}


Expand Down Expand Up @@ -578,7 +578,7 @@ impl BigUint {
let mut n: BigUint = Zero::zero();
let mut power: BigUint = One::one();
loop {
let start = uint::max(end, unit_len) - unit_len;
let start = max(end, unit_len) - unit_len;
match uint::parse_bytes(vec::slice(buf, start, end), radix) {
// FIXME(#6102): Assignment operator for BigInt causes ICE
// Some(d) => n += BigUint::from_uint(d) * power,
Expand Down Expand Up @@ -1053,9 +1053,9 @@ impl IntConvertible for BigInt {

fn to_int(&self) -> int {
match self.sign {
Plus => uint::min(self.to_uint(), int::max_value as uint) as int,
Plus => min(self.to_uint(), int::max_value as uint) as int,
Zero => 0,
Minus => uint::min((-self).to_uint(),
Minus => min((-self).to_uint(),
(int::max_value as uint) + 1) as int
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/par.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use core::prelude::*;

use core::iterator::IteratorUtil;
use core::cast;
use core::num;
use core::ptr;
use core::sys;
use core::uint;
use core::vec;
use future_spawn = future::spawn;

Expand Down Expand Up @@ -46,15 +46,15 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>(
~[f()(0u, xs)]
}
else {
let num_tasks = uint::min(max_tasks, len / min_granularity);
let num_tasks = num::min(max_tasks, len / min_granularity);

let items_per_task = len / num_tasks;

let mut futures = ~[];
let mut base = 0u;
info!("spawning tasks");
while base < len {
let end = uint::min(len, base + items_per_task);
let end = num::min(len, base + items_per_task);
do vec::as_imm_buf(xs) |p, _len| {
let f = f();
let base = base;
Expand Down
3 changes: 2 additions & 1 deletion src/libextra/rope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ pub mod node {
use core::str;
use core::uint;
use core::vec;
use core::num;

/// Implementation of type `rope`
pub enum Root {
Expand Down Expand Up @@ -1045,7 +1046,7 @@ pub mod node {
right: right,
char_len: char_len(left) + char_len(right),
byte_len: byte_len(left) + byte_len(right),
height: uint::max(height(left), height(right)) + 1u,
height: num::max(height(left), height(right)) + 1u,
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/libextra/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ mod test_qsort {

let expected = ~[1, 2, 3];

do quick_sort(names) |x, y| { int::le(*x, *y) };
do quick_sort(names) |x, y| { *x < *y };

let immut_names = names;

Expand Down
3 changes: 1 addition & 2 deletions src/libextra/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use core::prelude::*;

use core::iterator::*;
use core::vec;
use core::f64;
use core::cmp;
use core::num;
use sort;
Expand Down Expand Up @@ -82,7 +81,7 @@ impl<'self> Stats for &'self [f64] {
}

fn std_dev(self) -> f64 {
f64::sqrt(self.var())
num::sqrt(self.var())
}

fn std_dev_pct(self) -> f64 {
Expand Down
3 changes: 1 addition & 2 deletions src/libextra/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,7 @@ pub mod bench {
n = 1_000_000_000 / self.ns_per_iter();
}

n = u64::max(u64::min(n+n/2, 100*last), last+1);
n = round_up(n);
n = round_up((n + n/2).clamp(&(last + 1), &(100 * last)));
self.bench_n(n, f);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

use core::prelude::*;

use core::i32;
use core::int;
use core::io;
use core::num;
use core::str;
use core::iterator::IteratorUtil;

Expand Down Expand Up @@ -251,7 +251,7 @@ impl Tm {
} else {
let s = self.strftime("%Y-%m-%dT%H:%M:%S");
let sign = if self.tm_gmtoff > 0_i32 { '+' } else { '-' };
let mut m = i32::abs(self.tm_gmtoff) / 60_i32;
let mut m = num::abs(self.tm_gmtoff) / 60_i32;
let h = m / 60_i32;
m -= h * 60_i32;
s + fmt!("%c%02d:%02d", sign, h as int, m as int)
Expand Down Expand Up @@ -834,7 +834,7 @@ priv fn do_strftime(format: &str, tm: &Tm) -> ~str {
'Z' => copy tm.tm_zone,
'z' => {
let sign = if tm.tm_gmtoff > 0_i32 { '+' } else { '-' };
let mut m = i32::abs(tm.tm_gmtoff) / 60_i32;
let mut m = num::abs(tm.tm_gmtoff) / 60_i32;
let h = m / 60_i32;
m -= h * 60_i32;
fmt!("%c%02d%02d", sign, h as int, m as int)
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use core::prelude::*;

use core::iterator::*;
use core::uint;
use core::num;
use core::util::{swap, replace};

// This is implemented as an AA tree, which is a simplified variation of
Expand Down Expand Up @@ -65,7 +65,7 @@ fn lt<K: Ord + TotalOrd, V>(a: &TreeMap<K, V>,
let mut y = b.iter();

let (a_len, b_len) = (a.len(), b.len());
for uint::min(a_len, b_len).times {
for num::min(a_len, b_len).times {
let (key_a,_) = x.next().unwrap();
let (key_b,_) = y.next().unwrap();
if *key_a < *key_b { return true; }
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use metadata::cstore;
use metadata::filesearch;

use core::hashmap::HashSet;
use core::num;
use core::os;
use core::uint;
use core::util;
Expand Down Expand Up @@ -147,7 +148,7 @@ pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
assert!(len1 > 0);
assert!(len2 > 0);

let max_common_path = uint::min(len1, len2) - 1;
let max_common_path = num::min(len1, len2) - 1;
let mut start_idx = 0;
while start_idx < max_common_path
&& split1[start_idx] == split2[start_idx] {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ use syntax::{ast, attr};

use core::cast;
use core::io;
use core::num;
use core::option;
use core::os::consts::{macos, freebsd, linux, android, win32};
use core::ptr;
use core::str;
use core::uint;
use core::vec;
use extra::flate;

Expand Down Expand Up @@ -215,7 +215,7 @@ fn get_metadata_section(os: os,
let vlen = encoder::metadata_encoding_version.len();
debug!("checking %u bytes of metadata-version stamp",
vlen);
let minsz = uint::min(vlen, csz);
let minsz = num::min(vlen, csz);
let mut version_ok = false;
do vec::raw::buf_as_slice(cvbuf, minsz) |buf0| {
version_ok = (buf0 ==
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use middle::moves;
use util::ppaux::ty_to_str;

use core::iterator::IteratorUtil;
use core::num;
use core::uint;
use core::vec;
use extra::sort;
Expand Down Expand Up @@ -246,7 +247,7 @@ pub fn is_useful(cx: @MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful {
let max_len = do m.rev_iter().fold(0) |max_len, r| {
match r[0].node {
pat_vec(ref before, _, ref after) => {
uint::max(before.len() + after.len(), max_len)
num::max(before.len() + after.len(), max_len)
}
_ => max_len
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/cabi_arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use middle::trans::common::{T_array, T_ptr, T_void};

use core::iterator::IteratorUtil;
use core::option::{Option, None, Some};
use core::uint;
use core::num;

fn align_up_to(off: uint, a: uint) -> uint {
return (off + a - 1u) / a * a;
Expand All @@ -44,7 +44,7 @@ fn ty_align(ty: TypeRef) -> uint {
1
} else {
let str_tys = struct_tys(ty);
str_tys.iter().fold(1, |a, t| uint::max(a, ty_align(*t)))
str_tys.iter().fold(1, |a, t| num::max(a, ty_align(*t)))
}
}
Array => {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/trans/cabi_mips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use core::prelude::*;

use core::iterator::IteratorUtil;
use core::libc::c_uint;
use core::num;
use core::ptr;
use core::uint;
use core::vec;
use lib::llvm::{llvm, TypeRef, Integer, Pointer, Float, Double};
use lib::llvm::{Struct, Array, Attribute};
Expand Down Expand Up @@ -57,7 +57,7 @@ fn ty_align(ty: TypeRef) -> uint {
1
} else {
let str_tys = struct_tys(ty);
str_tys.iter().fold(1, |a, t| uint::max(a, ty_align(*t)))
str_tys.iter().fold(1, |a, t| num::max(a, ty_align(*t)))
}
}
Array => {
Expand Down Expand Up @@ -113,7 +113,7 @@ fn classify_arg_ty(ty: TypeRef,
let size = ty_size(ty) * 8;
let mut align = ty_align(ty);

align = uint::min(uint::max(align, 4), 8);
align = align.clamp(&4, &8);
*offset = align_up_to(*offset, align);
*offset += align_up_to(size, align * 8) / 8;

Expand Down
Loading