Skip to content

Commit

Permalink
Improve variable naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
TeXitoi committed Nov 14, 2013
1 parent 74d2731 commit d2bcc7b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/test/bench/shootout-meteor.rs
Expand Up @@ -63,20 +63,21 @@ impl<'self, T> Iterator<&'self T> for ListIterator<'self, T> {
// corresponding mirrored piece), with, as minimum coordinates, (0,
// 0). If all is false, only generate half of the possibilities (used
// to break the symetry of the board).
fn transform(p: ~[(int, int)], all: bool) -> ~[~[(int, int)]] {
fn transform(piece: ~[(int, int)], all: bool) -> ~[~[(int, int)]] {
let mut res =
// rotations
iterate(p, |p| p.iter().map(|&(y, x)| (x + y, -y)).collect())
iterate(piece, |rot| rot.iter().map(|&(y, x)| (x + y, -y)).collect())
.take(if all {6} else {3})
// mirror
.flat_map(|p| {
iterate(p, |p| p.iter().map(|&(y, x)| (x, y)).collect()).take(2)
.flat_map(|cur_piece| {
iterate(cur_piece, |mir| mir.iter().map(|&(y, x)| (x, y)).collect())
.take(2)
}).to_owned_vec();

// translating to (0, 0) as minimum coordinates.
for p in res.mut_iter() {
let (dy, dx) = *p.iter().min_by(|e| *e).unwrap();
for &(ref mut y, ref mut x) in p.mut_iter() {
for cur_piece in res.mut_iter() {
let (dy, dx) = *cur_piece.iter().min_by(|e| *e).unwrap();
for &(ref mut y, ref mut x) in cur_piece.mut_iter() {
*y -= dy; *x -= dx;
}
}
Expand Down

9 comments on commit d2bcc7b

@bors
Copy link
Contributor

@bors bors commented on d2bcc7b Nov 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at TeXitoi@d2bcc7b

@bors
Copy link
Contributor

@bors bors commented on d2bcc7b Nov 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging TeXitoi/rust/shootout-meteor = d2bcc7b into auto

@bors
Copy link
Contributor

@bors bors commented on d2bcc7b Nov 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeXitoi/rust/shootout-meteor = d2bcc7b merged ok, testing candidate = cf28c614

@bors
Copy link
Contributor

@bors bors commented on d2bcc7b Nov 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at TeXitoi@d2bcc7b

@bors
Copy link
Contributor

@bors bors commented on d2bcc7b Nov 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging TeXitoi/rust/shootout-meteor = d2bcc7b into auto

@bors
Copy link
Contributor

@bors bors commented on d2bcc7b Nov 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeXitoi/rust/shootout-meteor = d2bcc7b merged ok, testing candidate = 90754ae

@bors
Copy link
Contributor

@bors bors commented on d2bcc7b Nov 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on d2bcc7b Nov 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 90754ae

Please sign in to comment.