Skip to content

Commit 504e43e

Browse files
committed
---
yaml --- r: 42063 b: refs/heads/master c: 3a6849f h: refs/heads/master i: 42061: 7c5a5f8 42059: 25fad14 42055: 80ec33e 42047: f810075 v: v3
1 parent 0ead302 commit 504e43e

File tree

4 files changed

+23
-31
lines changed

4 files changed

+23
-31
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: abb79cb52de957a9c634ee2f7192627d92dd697f
2+
refs/heads/master: 3a6849f36b84f7387e08ecbb1adda811aaa9587a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/src/libstd/cmp.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
#[forbid(deprecated_mode)];
12-
//! Additional general-purpose comparison functionality.
12+
/// Additional general-purpose comparison functionality.
1313
1414
use core::f32;
1515
use core::f64;
@@ -18,30 +18,31 @@ use core::float;
1818
const fuzzy_epsilon: float = 1.0e-6;
1919

2020
pub trait FuzzyEq {
21-
pure fn fuzzy_eq(&self, other: &self) -> bool;
21+
pure fn fuzzy_eq(other: &self) -> bool;
2222
}
2323

2424
impl float: FuzzyEq {
25-
pure fn fuzzy_eq(&self, other: &float) -> bool {
26-
float::abs(*self - *other) < fuzzy_epsilon
25+
pure fn fuzzy_eq(other: &float) -> bool {
26+
return float::abs(self - *other) < fuzzy_epsilon;
2727
}
2828
}
2929

3030
impl f32: FuzzyEq {
31-
pure fn fuzzy_eq(&self, other: &f32) -> bool {
32-
f32::abs(*self - *other) < (fuzzy_epsilon as f32)
31+
pure fn fuzzy_eq(other: &f32) -> bool {
32+
return f32::abs(self - *other) < (fuzzy_epsilon as f32);
3333
}
3434
}
3535

3636
impl f64: FuzzyEq {
37-
pure fn fuzzy_eq(&self, other: &f64) -> bool {
38-
f64::abs(*self - *other) < (fuzzy_epsilon as f64)
37+
pure fn fuzzy_eq(other: &f64) -> bool {
38+
return f64::abs(self - *other) < (fuzzy_epsilon as f64);
3939
}
4040
}
4141

4242
#[test]
4343
fn test_fuzzy_equals() {
44-
assert (&1.0).fuzzy_eq(&1.0);
45-
assert (&1.0f32).fuzzy_eq(&1.0f32);
46-
assert (&1.0f64).fuzzy_eq(&1.0f64);
44+
assert ((&1.0).fuzzy_eq(&1.0));
45+
assert ((&1.0f32).fuzzy_eq(&1.0f32));
46+
assert ((&1.0f64).fuzzy_eq(&1.0f64));
4747
}
48+

trunk/src/libstd/priority_queue.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ impl <T: Ord> PriorityQueue<T> {
7676
}
7777

7878
/// Optimized version of a push followed by a pop
79-
fn push_pop(&mut self, item: T) -> T {
80-
let mut item = item;
79+
fn push_pop(&mut self, mut item: T) -> T {
8180
if !self.is_empty() && self.data[0] > item {
8281
item <-> self.data[0];
8382
self.siftdown(0);
@@ -86,8 +85,7 @@ impl <T: Ord> PriorityQueue<T> {
8685
}
8786

8887
/// Optimized version of a pop followed by a push - fails if empty
89-
fn replace(&mut self, item: T) -> T {
90-
let mut item = item;
88+
fn replace(&mut self, mut item: T) -> T {
9189
item <-> self.data[0];
9290
self.siftdown(0);
9391
item
@@ -129,9 +127,8 @@ impl <T: Ord> PriorityQueue<T> {
129127
// vector over the junk element. This reduces the constant factor
130128
// compared to using swaps, which involves twice as many moves.
131129

132-
priv fn siftup(&mut self, start: uint, pos: uint) {
130+
priv fn siftup(&mut self, start: uint, mut pos: uint) {
133131
unsafe {
134-
let mut pos = pos;
135132
let new = move *addr_of(&self.data[pos]);
136133

137134
while pos > start {
@@ -149,9 +146,8 @@ impl <T: Ord> PriorityQueue<T> {
149146
}
150147
}
151148

152-
priv fn siftdown_range(&mut self, pos: uint, end: uint) {
149+
priv fn siftdown_range(&mut self, mut pos: uint, end: uint) {
153150
unsafe {
154-
let mut pos = pos;
155151
let start = pos;
156152
let new = move *addr_of(&self.data[pos]);
157153

trunk/src/libstd/treemap.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,8 @@ pure fn each_reverse<K: Ord, V>(node: &Option<~TreeNode<K, V>>,
572572
}
573573

574574
// Remove left horizontal link by rotating right
575-
fn skew<K: Ord, V>(node: ~TreeNode<K, V>) -> ~TreeNode<K, V> {
575+
fn skew<K: Ord, V>(mut node: ~TreeNode<K, V>) -> ~TreeNode<K, V> {
576576
if node.left.map_default(false, |x| x.level == node.level) {
577-
let mut node = node;
578577
let mut save = node.left.swap_unwrap();
579578
node.left <-> save.right; // save.right now None
580579
save.right = Some(node);
@@ -586,10 +585,9 @@ fn skew<K: Ord, V>(node: ~TreeNode<K, V>) -> ~TreeNode<K, V> {
586585

587586
// Remove dual horizontal link by rotating left and increasing level of
588587
// the parent
589-
fn split<K: Ord, V>(node: ~TreeNode<K, V>) -> ~TreeNode<K, V> {
588+
fn split<K: Ord, V>(mut node: ~TreeNode<K, V>) -> ~TreeNode<K, V> {
590589
if node.right.map_default(false,
591590
|x| x.right.map_default(false, |y| y.level == node.level)) {
592-
let mut node = node;
593591
let mut save = node.right.swap_unwrap();
594592
node.right <-> save.left; // save.left now None
595593
save.left = Some(node);
@@ -628,8 +626,7 @@ fn remove<K: Ord, V>(node: &mut Option<~TreeNode<K, V>>, key: &K) -> bool {
628626
fn heir_swap<K: Ord, V>(node: &mut TreeNode<K, V>,
629627
child: &mut Option<~TreeNode<K, V>>) {
630628
// *could* be done without recursion, but it won't borrow check
631-
do child.mutate |child| {
632-
let mut child = child;
629+
do child.mutate |mut child| {
633630
if child.right.is_some() {
634631
heir_swap(&mut *node, &mut child.right);
635632
} else {
@@ -682,15 +679,13 @@ fn remove<K: Ord, V>(node: &mut Option<~TreeNode<K, V>>, key: &K) -> bool {
682679
save.level -= 1;
683680

684681
if right_level > save.level {
685-
do save.right.mutate |x| {
686-
let mut x = x; x.level = save.level; x
687-
}
682+
do save.right.mutate |mut x| { x.level = save.level; x }
688683
}
689684

690685
save = skew(save);
691686

692-
do save.right.mutate |right| {
693-
let mut right = skew(right);
687+
do save.right.mutate |mut right| {
688+
right = skew(right);
694689
right.right.mutate(skew);
695690
right
696691
}

0 commit comments

Comments
 (0)