Skip to content

Commit 7f45220

Browse files
committed
---
yaml --- r: 63603 b: refs/heads/snap-stage3 c: 66fd3c9 h: refs/heads/master i: 63601: 9e1e14c 63599: 6cc6d90 v: v3
1 parent a0172a4 commit 7f45220

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: de64ff20ab5f8c961ffda10c3bf168b52a8e4196
4+
refs/heads/snap-stage3: 66fd3c9e5dd8c9b44237b57f455ba60ef607958b
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/test/bench/shootout-fasta.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ use std::str;
2828
use std::uint;
2929
use std::vec;
3030

31-
fn LINE_LENGTH() -> uint { return 60u; }
31+
static LINE_LENGTH: uint = 60u;
32+
33+
//fn LINE_LENGTH() -> uint { return 60u; }
3234

3335
struct MyRandom {
3436
last: u32
@@ -81,7 +83,7 @@ fn make_random_fasta(wr: @io::Writer,
8183
for uint::range(0u, n as uint) |_i| {
8284
op.push_char(select_random(myrandom_next(rng, 100u32),
8385
copy genelist));
84-
if op.len() >= LINE_LENGTH() {
86+
if op.len() >= LINE_LENGTH {
8587
wr.write_line(op);
8688
op = ~"";
8789
}
@@ -90,18 +92,20 @@ fn make_random_fasta(wr: @io::Writer,
9092
}
9193

9294
fn make_repeat_fasta(wr: @io::Writer, id: ~str, desc: ~str, s: ~str, n: int) {
95+
wr.write_line(~">" + id + " " + desc);
96+
let mut op = str::with_capacity( LINE_LENGTH );
97+
let sl = s.len();
9398
unsafe {
94-
wr.write_line(~">" + id + " " + desc);
95-
let mut op: ~str = ~"";
96-
let sl: uint = s.len();
9799
for uint::range(0u, n as uint) |i| {
98-
str::raw::push_byte(&mut op, s[i % sl]);
99-
if op.len() >= LINE_LENGTH() {
100-
wr.write_line(op);
101-
op = ~"";
100+
if (op.len() >= LINE_LENGTH) {
101+
wr.write_line( op );
102+
op = str::with_capacity( LINE_LENGTH );
102103
}
104+
op.push_char( s[i % sl] as char );
105+
}
106+
if op.len() > 0 {
107+
wr.write_line(op)
103108
}
104-
if op.len() > 0u { wr.write_line(op); }
105109
}
106110
}
107111

0 commit comments

Comments
 (0)