Skip to content

Commit 2323757

Browse files
committed
---
yaml --- r: 60247 b: refs/heads/master c: 4f8084a h: refs/heads/master i: 60245: 4d7946a 60243: 9bd989b 60239: ecb8845 v: v3
1 parent e69e595 commit 2323757

File tree

11 files changed

+136
-253
lines changed

11 files changed

+136
-253
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 2a9a4a81e15fbd8146ce8fe5842c46ad615cbcf6
2+
refs/heads/master: 4f8084a363b352e4a1d75f9ab53f6defcb65d366
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589

trunk/src/driver/driver.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[no_core];
12+
extern mod core(vers = "0.7-pre");
13+
1114
#[cfg(rustpkg)]
1215
extern mod this(name = "rustpkg", vers = "0.7-pre");
1316

trunk/src/libcore/num/f32.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,7 @@ impl Float for f32 {
578578
/// Returns `true` if the number is neither zero, infinite, subnormal or NaN
579579
#[inline(always)]
580580
fn is_normal(&self) -> bool {
581-
match self.classify() {
582-
FPNormal => true,
583-
_ => false,
584-
}
581+
self.classify() == FPNormal
585582
}
586583

587584
/// Returns the floating point category of the number. If only one property is going to
@@ -591,14 +588,14 @@ impl Float for f32 {
591588
static MAN_MASK: u32 = 0x007fffff;
592589

593590
match (
591+
unsafe { ::cast::transmute::<f32,u32>(*self) } & MAN_MASK,
594592
unsafe { ::cast::transmute::<f32,u32>(*self) } & EXP_MASK,
595-
unsafe { ::cast::transmute::<f32,u32>(*self) } & MAN_MASK
596593
) {
597-
(EXP_MASK, 0) => FPInfinite,
598-
(EXP_MASK, _) => FPNaN,
599-
(exp, _) if exp != 0 => FPNormal,
600-
_ if self.is_zero() => FPZero,
601-
_ => FPSubnormal,
594+
(0, 0) => FPZero,
595+
(_, 0) => FPSubnormal,
596+
(0, EXP_MASK) => FPInfinite,
597+
(_, EXP_MASK) => FPNaN,
598+
_ => FPNormal,
602599
}
603600
}
604601

trunk/src/libcore/num/f64.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,7 @@ impl Float for f64 {
621621
/// Returns `true` if the number is neither zero, infinite, subnormal or NaN
622622
#[inline(always)]
623623
fn is_normal(&self) -> bool {
624-
match self.classify() {
625-
FPNormal => true,
626-
_ => false,
627-
}
624+
self.classify() == FPNormal
628625
}
629626

630627
/// Returns the floating point category of the number. If only one property is going to
@@ -634,14 +631,14 @@ impl Float for f64 {
634631
static MAN_MASK: u64 = 0x000fffffffffffff;
635632

636633
match (
634+
unsafe { ::cast::transmute::<f64,u64>(*self) } & MAN_MASK,
637635
unsafe { ::cast::transmute::<f64,u64>(*self) } & EXP_MASK,
638-
unsafe { ::cast::transmute::<f64,u64>(*self) } & MAN_MASK
639636
) {
640-
(EXP_MASK, 0) => FPInfinite,
641-
(EXP_MASK, _) => FPNaN,
642-
(exp, _) if exp != 0 => FPNormal,
643-
_ if self.is_zero() => FPZero,
644-
_ => FPSubnormal,
637+
(0, 0) => FPZero,
638+
(_, 0) => FPSubnormal,
639+
(0, EXP_MASK) => FPInfinite,
640+
(_, EXP_MASK) => FPNaN,
641+
_ => FPNormal,
645642
}
646643
}
647644

trunk/src/libcore/to_str.rs

Lines changed: 14 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ The `ToStr` trait for converting to strings
1414
1515
*/
1616

17-
use str::OwnedStr;
18-
use hashmap::HashMap;
19-
use hashmap::HashSet;
20-
use container::Map;
21-
use hash::Hash;
22-
use cmp::Eq;
17+
use str;
2318

2419
pub trait ToStr {
2520
fn to_str(&self) -> ~str;
@@ -51,44 +46,6 @@ impl<A:ToStr> ToStr for (A,) {
5146
}
5247
}
5348

54-
impl<A:ToStr+Hash+Eq, B:ToStr+Hash+Eq> ToStr for HashMap<A, B> {
55-
#[inline(always)]
56-
fn to_str(&self) -> ~str {
57-
let mut acc = ~"{", first = true;
58-
for self.each |key, value| {
59-
if first {
60-
first = false;
61-
}
62-
else {
63-
acc.push_str(", ");
64-
}
65-
acc.push_str(key.to_str());
66-
acc.push_str(": ");
67-
acc.push_str(value.to_str());
68-
}
69-
acc.push_char('}');
70-
acc
71-
}
72-
}
73-
74-
impl<A:ToStr+Hash+Eq> ToStr for HashSet<A> {
75-
#[inline(always)]
76-
fn to_str(&self) -> ~str {
77-
let mut acc = ~"{", first = true;
78-
for self.each |element| {
79-
if first {
80-
first = false;
81-
}
82-
else {
83-
acc.push_str(", ");
84-
}
85-
acc.push_str(element.to_str());
86-
}
87-
acc.push_char('}');
88-
acc
89-
}
90-
}
91-
9249
impl<A:ToStr,B:ToStr> ToStr for (A, B) {
9350
#[inline(always)]
9451
fn to_str(&self) -> ~str {
@@ -101,7 +58,6 @@ impl<A:ToStr,B:ToStr> ToStr for (A, B) {
10158
}
10259
}
10360
}
104-
10561
impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
10662
#[inline(always)]
10763
fn to_str(&self) -> ~str {
@@ -124,15 +80,11 @@ impl<'self,A:ToStr> ToStr for &'self [A] {
12480
fn to_str(&self) -> ~str {
12581
let mut acc = ~"[", first = true;
12682
for self.each |elt| {
127-
if first {
128-
first = false;
129-
}
130-
else {
131-
acc.push_str(", ");
132-
}
133-
acc.push_str(elt.to_str());
83+
if first { first = false; }
84+
else { str::push_str(&mut acc, ~", "); }
85+
str::push_str(&mut acc, elt.to_str());
13486
}
135-
acc.push_char(']');
87+
str::push_char(&mut acc, ']');
13688
acc
13789
}
13890
}
@@ -142,15 +94,11 @@ impl<A:ToStr> ToStr for ~[A] {
14294
fn to_str(&self) -> ~str {
14395
let mut acc = ~"[", first = true;
14496
for self.each |elt| {
145-
if first {
146-
first = false;
147-
}
148-
else {
149-
acc.push_str(", ");
150-
}
151-
acc.push_str(elt.to_str());
97+
if first { first = false; }
98+
else { str::push_str(&mut acc, ~", "); }
99+
str::push_str(&mut acc, elt.to_str());
152100
}
153-
acc.push_char(']');
101+
str::push_char(&mut acc, ']');
154102
acc
155103
}
156104
}
@@ -160,25 +108,18 @@ impl<A:ToStr> ToStr for @[A] {
160108
fn to_str(&self) -> ~str {
161109
let mut acc = ~"[", first = true;
162110
for self.each |elt| {
163-
if first {
164-
first = false;
165-
}
166-
else {
167-
acc.push_str(", ");
168-
}
169-
acc.push_str(elt.to_str());
111+
if first { first = false; }
112+
else { str::push_str(&mut acc, ~", "); }
113+
str::push_str(&mut acc, elt.to_str());
170114
}
171-
acc.push_char(']');
115+
str::push_char(&mut acc, ']');
172116
acc
173117
}
174118
}
175119
176120
#[cfg(test)]
177121
#[allow(non_implicitly_copyable_typarams)]
178122
mod tests {
179-
use hashmap::HashMap;
180-
use hashmap::HashSet;
181-
use container::Set;
182123
#[test]
183124
fn test_simple_types() {
184125
assert!(1i.to_str() == ~"1");
@@ -208,32 +149,4 @@ mod tests {
208149
assert!((~[~[], ~[1], ~[1, 1]]).to_str() ==
209150
~"[[], [1], [1, 1]]");
210151
}
211-
212-
#[test]
213-
fn test_hashmap() {
214-
let mut table: HashMap<int, int> = HashMap::new();
215-
let empty: HashMap<int, int> = HashMap::new();
216-
217-
table.insert(3, 4);
218-
table.insert(1, 2);
219-
220-
let table_str = table.to_str();
221-
222-
assert!(table_str == ~"{1: 2, 3: 4}" || table_str == ~"{3: 4, 1: 2}");
223-
assert!(empty.to_str() == ~"{}");
224-
}
225-
226-
#[test]
227-
fn test_hashset() {
228-
let mut set: HashSet<int> = HashSet::new();
229-
let empty_set: HashSet<int> = HashSet::new();
230-
231-
set.insert(1);
232-
set.insert(2);
233-
234-
let set_str = set.to_str();
235-
236-
assert!(set_str == ~"{1, 2}" || set_str == ~"{2, 1}");
237-
assert!(empty_set.to_str() == ~"{}");
238-
}
239-
}
152+
}

0 commit comments

Comments
 (0)