Skip to content

Commit 988e4f0

Browse files
committed
Uppercase numeric constants
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
1 parent de57a22 commit 988e4f0

36 files changed

+444
-444
lines changed

src/libextra/bitv.rs

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -121,8 +121,8 @@ struct BigBitv {
121121
*/
122122
#[inline]
123123
fn big_mask(nbits: uint, elem: uint) -> uint {
124-
let rmd = nbits % uint::bits;
125-
let nelems = nbits/uint::bits + if rmd == 0 {0} else {1};
124+
let rmd = nbits % uint::BITS;
125+
let nelems = nbits/uint::BITS + if rmd == 0 {0} else {1};
126126

127127
if elem < nelems - 1 || rmd == 0 {
128128
!0
@@ -192,16 +192,16 @@ impl BigBitv {
192192

193193
#[inline]
194194
pub fn get(&self, i: uint) -> bool {
195-
let w = i / uint::bits;
196-
let b = i % uint::bits;
195+
let w = i / uint::BITS;
196+
let b = i % uint::BITS;
197197
let x = 1 & self.storage[w] >> b;
198198
x == 1
199199
}
200200

201201
#[inline]
202202
pub fn set(&mut self, i: uint, x: bool) {
203-
let w = i / uint::bits;
204-
let b = i % uint::bits;
203+
let w = i / uint::BITS;
204+
let b = i % uint::BITS;
205205
let flag = 1 << b;
206206
self.storage[w] = if x { self.storage[w] | flag }
207207
else { self.storage[w] & !flag };
@@ -269,20 +269,20 @@ impl Bitv {
269269

270270
impl Bitv {
271271
pub fn new(nbits: uint, init: bool) -> Bitv {
272-
let rep = if nbits < uint::bits {
272+
let rep = if nbits < uint::BITS {
273273
Small(SmallBitv::new(if init {(1<<nbits)-1} else {0}))
274-
} else if nbits == uint::bits {
274+
} else if nbits == uint::BITS {
275275
Small(SmallBitv::new(if init {!0} else {0}))
276276
} else {
277-
let exact = nbits % uint::bits == 0;
278-
let nelems = nbits/uint::bits + if exact {0} else {1};
277+
let exact = nbits % uint::BITS == 0;
278+
let nelems = nbits/uint::BITS + if exact {0} else {1};
279279
let s =
280280
if init {
281281
if exact {
282282
vec::from_elem(nelems, !0u)
283283
} else {
284284
let mut v = vec::from_elem(nelems-1, !0u);
285-
v.push((1<<nbits % uint::bits)-1);
285+
v.push((1<<nbits % uint::BITS)-1);
286286
v
287287
}
288288
} else { vec::from_elem(nelems, 0u)};
@@ -576,7 +576,7 @@ fn iterate_bits(base: uint, bits: uint, f: |uint| -> bool) -> bool {
576576
if bits == 0 {
577577
return true;
578578
}
579-
for i in range(0u, uint::bits) {
579+
for i in range(0u, uint::BITS) {
580580
if bits & (1 << i) != 0 {
581581
if !f(base + i) {
582582
return false;
@@ -680,7 +680,7 @@ impl BitvSet {
680680

681681
/// Returns the capacity in bits for this bit vector. Inserting any
682682
/// element less than this amount will not trigger a resizing.
683-
pub fn capacity(&self) -> uint { self.bitv.storage.len() * uint::bits }
683+
pub fn capacity(&self) -> uint { self.bitv.storage.len() * uint::BITS }
684684

685685
/// Consumes this set to return the underlying bit vector
686686
pub fn unwrap(self) -> Bitv {
@@ -693,7 +693,7 @@ impl BitvSet {
693693
fn other_op(&mut self, other: &BitvSet, f: |uint, uint| -> uint) {
694694
fn nbits(mut w: uint) -> uint {
695695
let mut bits = 0;
696-
for _ in range(0u, uint::bits) {
696+
for _ in range(0u, uint::BITS) {
697697
if w == 0 {
698698
break;
699699
}
@@ -703,7 +703,7 @@ impl BitvSet {
703703
return bits;
704704
}
705705
if self.capacity() < other.capacity() {
706-
self.bitv.storage.grow(other.capacity() / uint::bits, &0);
706+
self.bitv.storage.grow(other.capacity() / uint::BITS, &0);
707707
}
708708
for (i, &w) in other.bitv.storage.iter().enumerate() {
709709
let old = self.bitv.storage[i];
@@ -808,7 +808,7 @@ impl Mutable for BitvSet {
808808

809809
impl Set<uint> for BitvSet {
810810
fn contains(&self, value: &uint) -> bool {
811-
*value < self.bitv.storage.len() * uint::bits && self.bitv.get(*value)
811+
*value < self.bitv.storage.len() * uint::BITS && self.bitv.get(*value)
812812
}
813813

814814
fn is_disjoint(&self, other: &BitvSet) -> bool {
@@ -846,7 +846,7 @@ impl MutableSet<uint> for BitvSet {
846846
}
847847
let nbits = self.capacity();
848848
if value >= nbits {
849-
let newsize = num::max(value, nbits * 2) / uint::bits + 1;
849+
let newsize = num::max(value, nbits * 2) / uint::BITS + 1;
850850
assert!(newsize > self.bitv.storage.len());
851851
self.bitv.storage.grow(newsize, &0);
852852
}
@@ -884,7 +884,7 @@ impl BitvSet {
884884
let min = num::min(self.bitv.storage.len(), other.bitv.storage.len());
885885
self.bitv.storage.slice(0, min).iter().enumerate()
886886
.zip(Repeat::new(&other.bitv.storage))
887-
.map(|((i, &w), o_store)| (i * uint::bits, w, o_store[i]))
887+
.map(|((i, &w), o_store)| (i * uint::BITS, w, o_store[i]))
888888
}
889889

890890
/// Visits each word in `self` or `other` that extends beyond the other. This
@@ -903,11 +903,11 @@ impl BitvSet {
903903
if olen < slen {
904904
self.bitv.storage.slice_from(olen).iter().enumerate()
905905
.zip(Repeat::new(olen))
906-
.map(|((i, &w), min)| (true, (i + min) * uint::bits, w))
906+
.map(|((i, &w), min)| (true, (i + min) * uint::BITS, w))
907907
} else {
908908
other.bitv.storage.slice_from(slen).iter().enumerate()
909909
.zip(Repeat::new(slen))
910-
.map(|((i, &w), min)| (false, (i + min) * uint::bits, w))
910+
.map(|((i, &w), min)| (false, (i + min) * uint::BITS, w))
911911
}
912912
}
913913
}
@@ -1529,7 +1529,7 @@ mod tests {
15291529

15301530
assert!(a.insert(1000));
15311531
assert!(a.remove(&1000));
1532-
assert_eq!(a.capacity(), uint::bits);
1532+
assert_eq!(a.capacity(), uint::BITS);
15331533
}
15341534

15351535
#[test]
@@ -1561,16 +1561,16 @@ mod tests {
15611561
let mut r = rng();
15621562
let mut bitv = 0 as uint;
15631563
b.iter(|| {
1564-
bitv |= (1 << ((r.next_u32() as uint) % uint::bits));
1564+
bitv |= (1 << ((r.next_u32() as uint) % uint::BITS));
15651565
})
15661566
}
15671567

15681568
#[bench]
15691569
fn bench_small_bitv_small(b: &mut BenchHarness) {
15701570
let mut r = rng();
1571-
let mut bitv = SmallBitv::new(uint::bits);
1571+
let mut bitv = SmallBitv::new(uint::BITS);
15721572
b.iter(|| {
1573-
bitv.set((r.next_u32() as uint) % uint::bits, true);
1573+
bitv.set((r.next_u32() as uint) % uint::BITS, true);
15741574
})
15751575
}
15761576

@@ -1579,15 +1579,15 @@ mod tests {
15791579
let mut r = rng();
15801580
let mut bitv = BigBitv::new(~[0]);
15811581
b.iter(|| {
1582-
bitv.set((r.next_u32() as uint) % uint::bits, true);
1582+
bitv.set((r.next_u32() as uint) % uint::BITS, true);
15831583
})
15841584
}
15851585

15861586
#[bench]
15871587
fn bench_big_bitv_big(b: &mut BenchHarness) {
15881588
let mut r = rng();
15891589
let mut storage = ~[];
1590-
storage.grow(BENCH_BITS / uint::bits, &0u);
1590+
storage.grow(BENCH_BITS / uint::BITS, &0u);
15911591
let mut bitv = BigBitv::new(storage);
15921592
b.iter(|| {
15931593
bitv.set((r.next_u32() as uint) % BENCH_BITS, true);
@@ -1606,9 +1606,9 @@ mod tests {
16061606
#[bench]
16071607
fn bench_bitv_small(b: &mut BenchHarness) {
16081608
let mut r = rng();
1609-
let mut bitv = Bitv::new(uint::bits, false);
1609+
let mut bitv = Bitv::new(uint::BITS, false);
16101610
b.iter(|| {
1611-
bitv.set((r.next_u32() as uint) % uint::bits, true);
1611+
bitv.set((r.next_u32() as uint) % uint::BITS, true);
16121612
})
16131613
}
16141614

@@ -1617,7 +1617,7 @@ mod tests {
16171617
let mut r = rng();
16181618
let mut bitv = BitvSet::new();
16191619
b.iter(|| {
1620-
bitv.insert((r.next_u32() as uint) % uint::bits);
1620+
bitv.insert((r.next_u32() as uint) % uint::BITS);
16211621
})
16221622
}
16231623

@@ -1641,7 +1641,7 @@ mod tests {
16411641

16421642
#[bench]
16431643
fn bench_btv_small_iter(b: &mut BenchHarness) {
1644-
let bitv = Bitv::new(uint::bits, false);
1644+
let bitv = Bitv::new(uint::BITS, false);
16451645
b.iter(|| {
16461646
let mut _sum = 0;
16471647
for pres in bitv.iter() {

src/libextra/ebml.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -364,7 +364,7 @@ pub mod reader {
364364
fn read_u8 (&mut self) -> u8 { doc_as_u8 (self.next_doc(EsU8 )) }
365365
fn read_uint(&mut self) -> uint {
366366
let v = doc_as_u64(self.next_doc(EsUint));
367-
if v > (::std::uint::max_value as u64) {
367+
if v > (::std::uint::MAX as u64) {
368368
fail!("uint {} too large for this architecture", v);
369369
}
370370
v as uint
@@ -384,7 +384,7 @@ pub mod reader {
384384
}
385385
fn read_int(&mut self) -> int {
386386
let v = doc_as_u64(self.next_doc(EsInt)) as i64;
387-
if v > (int::max_value as i64) || v < (int::min_value as i64) {
387+
if v > (int::MAX as i64) || v < (int::MIN as i64) {
388388
debug!("FIXME \\#6122: Removing this makes this function miscompile");
389389
fail!("int {} out of range for this architecture", v);
390390
}

src/libextra/getopts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -848,7 +848,7 @@ pub mod groups {
848848
t("hello", 15, [~"hello"]);
849849
t("\nMary had a little lamb\nLittle lamb\n", 15,
850850
[~"Mary had a", ~"little lamb", ~"Little lamb"]);
851-
t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::max_value,
851+
t("\nMary had a little lamb\nLittle lamb\n", ::std::uint::MAX,
852852
[~"Mary had a little lamb\nLittle lamb"]);
853853
}
854854
} // end groups module

src/libextra/num/bigint.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -1186,7 +1186,7 @@ impl ToPrimitive for BigInt {
11861186
if n < m {
11871187
Some(-(n as i64))
11881188
} else if n == m {
1189-
Some(i64::min_value)
1189+
Some(i64::MIN)
11901190
} else {
11911191
None
11921192
}
@@ -1213,7 +1213,7 @@ impl FromPrimitive for BigInt {
12131213
Some(BigInt::from_biguint(Plus, n))
12141214
})
12151215
} else if n < 0 {
1216-
FromPrimitive::from_u64(u64::max_value - (n as u64) + 1).and_then(
1216+
FromPrimitive::from_u64(u64::MAX - (n as u64) + 1).and_then(
12171217
|n| {
12181218
Some(BigInt::from_biguint(Minus, n))
12191219
})
@@ -1625,7 +1625,7 @@ mod biguint_tests {
16251625

16261626
check(Zero::zero(), 0);
16271627
check(One::one(), 1);
1628-
check(i64::max_value.to_biguint().unwrap(), i64::max_value);
1628+
check(i64::MAX.to_biguint().unwrap(), i64::MAX);
16291629

16301630
check(BigUint::new(~[ ]), 0);
16311631
check(BigUint::new(~[ 1 ]), (1 << (0*BigDigit::bits)));
@@ -1635,9 +1635,9 @@ mod biguint_tests {
16351635
check(BigUint::new(~[ 0, 0, 1 ]), (1 << (2*BigDigit::bits)));
16361636
check(BigUint::new(~[-1, -1, -1 ]), (1 << (3*BigDigit::bits)) - 1);
16371637
check(BigUint::new(~[ 0, 0, 0, 1 ]), (1 << (3*BigDigit::bits)));
1638-
check(BigUint::new(~[-1, -1, -1, -1 >> 1]), i64::max_value);
1638+
check(BigUint::new(~[-1, -1, -1, -1 >> 1]), i64::MAX);
16391639

1640-
assert_eq!(i64::min_value.to_biguint(), None);
1640+
assert_eq!(i64::MIN.to_biguint(), None);
16411641
assert_eq!(BigUint::new(~[-1, -1, -1, -1 ]).to_i64(), None);
16421642
assert_eq!(BigUint::new(~[ 0, 0, 0, 0, 1]).to_i64(), None);
16431643
assert_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_i64(), None);
@@ -1654,15 +1654,15 @@ mod biguint_tests {
16541654

16551655
check(Zero::zero(), 0);
16561656
check(One::one(), 1);
1657-
check(i64::max_value.to_biguint().unwrap(), i64::max_value);
1657+
check(i64::MAX.to_biguint().unwrap(), i64::MAX);
16581658

16591659
check(BigUint::new(~[ ]), 0);
16601660
check(BigUint::new(~[ 1 ]), (1 << (0*BigDigit::bits)));
16611661
check(BigUint::new(~[-1 ]), (1 << (1*BigDigit::bits)) - 1);
16621662
check(BigUint::new(~[ 0, 1 ]), (1 << (1*BigDigit::bits)));
1663-
check(BigUint::new(~[-1, -1 >> 1]), i64::max_value);
1663+
check(BigUint::new(~[-1, -1 >> 1]), i64::MAX);
16641664

1665-
assert_eq!(i64::min_value.to_biguint(), None);
1665+
assert_eq!(i64::MIN.to_biguint(), None);
16661666
assert_eq!(BigUint::new(~[-1, -1 ]).to_i64(), None);
16671667
assert_eq!(BigUint::new(~[ 0, 0, 1]).to_i64(), None);
16681668
assert_eq!(BigUint::new(~[-1, -1, -1]).to_i64(), None);
@@ -1679,8 +1679,8 @@ mod biguint_tests {
16791679

16801680
check(Zero::zero(), 0);
16811681
check(One::one(), 1);
1682-
check(u64::min_value.to_biguint().unwrap(), u64::min_value);
1683-
check(u64::max_value.to_biguint().unwrap(), u64::max_value);
1682+
check(u64::MIN.to_biguint().unwrap(), u64::MIN);
1683+
check(u64::MAX.to_biguint().unwrap(), u64::MAX);
16841684

16851685
check(BigUint::new(~[ ]), 0);
16861686
check(BigUint::new(~[ 1 ]), (1 << (0*BigDigit::bits)));
@@ -1690,7 +1690,7 @@ mod biguint_tests {
16901690
check(BigUint::new(~[ 0, 0, 1 ]), (1 << (2*BigDigit::bits)));
16911691
check(BigUint::new(~[-1, -1, -1 ]), (1 << (3*BigDigit::bits)) - 1);
16921692
check(BigUint::new(~[ 0, 0, 0, 1]), (1 << (3*BigDigit::bits)));
1693-
check(BigUint::new(~[-1, -1, -1, -1]), u64::max_value);
1693+
check(BigUint::new(~[-1, -1, -1, -1]), u64::MAX);
16941694

16951695
assert_eq!(BigUint::new(~[ 0, 0, 0, 0, 1]).to_u64(), None);
16961696
assert_eq!(BigUint::new(~[-1, -1, -1, -1, -1]).to_u64(), None);
@@ -1707,14 +1707,14 @@ mod biguint_tests {
17071707

17081708
check(Zero::zero(), 0);
17091709
check(One::one(), 1);
1710-
check(u64::min_value.to_biguint().unwrap(), u64::min_value);
1711-
check(u64::max_value.to_biguint().unwrap(), u64::max_value);
1710+
check(u64::MIN.to_biguint().unwrap(), u64::MIN);
1711+
check(u64::MAX.to_biguint().unwrap(), u64::MAX);
17121712

17131713
check(BigUint::new(~[ ]), 0);
17141714
check(BigUint::new(~[ 1 ]), (1 << (0*BigDigit::bits)));
17151715
check(BigUint::new(~[-1 ]), (1 << (1*BigDigit::bits)) - 1);
17161716
check(BigUint::new(~[ 0, 1]), (1 << (1*BigDigit::bits)));
1717-
check(BigUint::new(~[-1, -1]), u64::max_value);
1717+
check(BigUint::new(~[-1, -1]), u64::MAX);
17181718

17191719
assert_eq!(BigUint::new(~[ 0, 0, 1]).to_u64(), None);
17201720
assert_eq!(BigUint::new(~[-1, -1, -1]).to_u64(), None);
@@ -2166,11 +2166,11 @@ mod bigint_tests {
21662166

21672167
check(Zero::zero(), 0);
21682168
check(One::one(), 1);
2169-
check(i64::min_value.to_bigint().unwrap(), i64::min_value);
2170-
check(i64::max_value.to_bigint().unwrap(), i64::max_value);
2169+
check(i64::MIN.to_bigint().unwrap(), i64::MIN);
2170+
check(i64::MAX.to_bigint().unwrap(), i64::MAX);
21712171

21722172
assert_eq!(
2173-
(i64::max_value as u64 + 1).to_bigint().unwrap().to_i64(),
2173+
(i64::MAX as u64 + 1).to_bigint().unwrap().to_i64(),
21742174
None);
21752175

21762176
assert_eq!(
@@ -2196,14 +2196,14 @@ mod bigint_tests {
21962196

21972197
check(Zero::zero(), 0);
21982198
check(One::one(), 1);
2199-
check(u64::min_value.to_bigint().unwrap(), u64::min_value);
2200-
check(u64::max_value.to_bigint().unwrap(), u64::max_value);
2199+
check(u64::MIN.to_bigint().unwrap(), u64::MIN);
2200+
check(u64::MAX.to_bigint().unwrap(), u64::MAX);
22012201

22022202
assert_eq!(
22032203
BigInt::from_biguint(Plus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(),
22042204
None);
22052205

2206-
let max_value: BigUint = FromPrimitive::from_u64(u64::max_value).unwrap();
2206+
let max_value: BigUint = FromPrimitive::from_u64(u64::MAX).unwrap();
22072207
assert_eq!(BigInt::from_biguint(Minus, max_value).to_u64(), None);
22082208
assert_eq!(BigInt::from_biguint(Minus, BigUint::new(~[1, 2, 3, 4, 5])).to_u64(), None);
22092209
}

0 commit comments

Comments
 (0)