Skip to content

Commit 42f9399

Browse files
committed
---
yaml --- r: 41582 b: refs/heads/master c: f4bc9e6 h: refs/heads/master v: v3
1 parent 1485b9b commit 42f9399

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
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: 51b141e3e499558ddfece1f00dd6714f442c2404
2+
refs/heads/master: f4bc9e6d57c1e005c6539db59762e4030bd7bd2f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/src/libcore/extfmt.rs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -243,31 +243,24 @@ pub mod ct {
243243
}
244244
pub fn parse_flags(s: &str, i: uint, lim: uint) ->
245245
Parsed<~[Flag]> {
246-
let noflags: ~[Flag] = ~[];
247-
if i >= lim { return Parsed::new(move noflags, i); }
248-
249-
fn more(f: Flag, s: &str, i: uint, lim: uint) ->
250-
Parsed<~[Flag]> {
251-
let next = parse_flags(s, i + 1u, lim);
252-
let rest = copy next.val;
253-
let j = next.next;
254-
let curr: ~[Flag] = ~[f];
255-
return Parsed::new(vec::append(move curr, rest), j);
246+
let mut i = i;
247+
let mut flags = ~[];
248+
249+
while i < lim {
250+
let f = match s[i] {
251+
'-' as u8 => FlagLeftJustify,
252+
'0' as u8 => FlagLeftZeroPad,
253+
' ' as u8 => FlagSpaceForSign,
254+
'+' as u8 => FlagSignAlways,
255+
'#' as u8 => FlagAlternate,
256+
_ => break
257+
};
258+
259+
flags.push(f);
260+
i += 1;
256261
}
257-
// Unfortunate, but because s is borrowed, can't use a closure
258-
// fn more(f: Flag, s: &str) { more_(f, s, i, lim); }
259-
let f = s[i];
260-
return if f == '-' as u8 {
261-
more(FlagLeftJustify, s, i, lim)
262-
} else if f == '0' as u8 {
263-
more(FlagLeftZeroPad, s, i, lim)
264-
} else if f == ' ' as u8 {
265-
more(FlagSpaceForSign, s, i, lim)
266-
} else if f == '+' as u8 {
267-
more(FlagSignAlways, s, i, lim)
268-
} else if f == '#' as u8 {
269-
more(FlagAlternate, s, i, lim)
270-
} else { Parsed::new(move noflags, i) };
262+
263+
Parsed::new(flags, i)
271264
}
272265
pub fn parse_count(s: &str, i: uint, lim: uint)
273266
-> Parsed<Count> {

0 commit comments

Comments
 (0)