1
- // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1
+ // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2
2
// file at the top-level directory of this distribution and at
3
3
// http://rust-lang.org/COPYRIGHT.
4
4
//
@@ -19,19 +19,15 @@ extern mod extra;
19
19
20
20
use std:: int;
21
21
use std:: io;
22
- use std:: option;
23
22
use std:: os;
24
23
use std:: rand:: Rng ;
25
24
use std:: rand;
26
25
use std:: result;
27
26
use std:: str;
28
27
use std:: uint;
29
- use std:: vec;
30
28
31
29
static LINE_LENGTH : uint = 60 u;
32
30
33
- //fn LINE_LENGTH() -> uint { return 60u; }
34
-
35
31
struct MyRandom {
36
32
last : u32
37
33
}
@@ -95,17 +91,15 @@ fn make_repeat_fasta(wr: @io::Writer, id: ~str, desc: ~str, s: ~str, n: int) {
95
91
wr. write_line ( ~">" + id + " " + desc);
96
92
let mut op = str::with_capacity( LINE_LENGTH );
97
93
let sl = s.len();
98
- unsafe {
99
- for uint::range(0u, n as uint) |i| {
100
- if (op.len() >= LINE_LENGTH) {
101
- wr.write_line( op );
102
- op = str::with_capacity( LINE_LENGTH );
103
- }
104
- op.push_char( s[i % sl] as char );
105
- }
106
- if op.len() > 0 {
107
- wr.write_line(op)
94
+ for uint::range(0u, n as uint) |i| {
95
+ if (op.len() >= LINE_LENGTH) {
96
+ wr.write_line( op );
97
+ op = str::with_capacity( LINE_LENGTH );
108
98
}
99
+ op.push_char( s[i % sl] as char );
100
+ }
101
+ if op.len() > 0 {
102
+ wr.write_line(op)
109
103
}
110
104
}
111
105
@@ -115,7 +109,7 @@ fn acid(ch: char, prob: u32) -> AminoAcids {
115
109
116
110
fn main() {
117
111
let args = os::args();
118
- let args = if os::getenv(~ " RUST_BENCH ") . is_some ( ) {
112
+ let args = if os::getenv(" RUST_BENCH ") . is_some ( ) {
119
113
// alioth tests k-nucleotide with this data at 25,000,000
120
114
~[ ~"", ~"5000000 "]
121
115
} else if args. len ( ) <= 1 u {
@@ -124,9 +118,9 @@ fn main() {
124
118
args
125
119
} ;
126
120
127
- let writer = if os:: getenv ( ~ "RUST_BENCH ") . is_some ( ) {
121
+ let writer = if os:: getenv ( "RUST_BENCH" ) . is_some ( ) {
128
122
result:: get ( & io:: file_writer ( & Path ( "./shootout-fasta.data" ) ,
129
- ~ [ io:: Truncate , io:: Create ] ) )
123
+ [ io:: Truncate , io:: Create ] ) )
130
124
} else {
131
125
io:: stdout ( )
132
126
} ;
0 commit comments