Skip to content

Commit 1485b9b

Browse files
committed
---
yaml --- r: 41581 b: refs/heads/master c: 51b141e h: refs/heads/master i: 41579: 1e04bee v: v3
1 parent 1dba6bf commit 1485b9b

File tree

2 files changed

+16
-27
lines changed

2 files changed

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

trunk/src/libcore/extfmt.rs

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -310,34 +310,23 @@ pub mod ct {
310310
pub fn parse_type(s: &str, i: uint, lim: uint, err: ErrorFn) ->
311311
Parsed<Ty> {
312312
if i >= lim { err(~"missing type in conversion"); }
313-
let tstr = str::slice(s, i, i+1u);
314313
// FIXME (#2249): Do we really want two signed types here?
315314
// How important is it to be printf compatible?
316-
let t =
317-
if tstr == ~"b" {
318-
TyBool
319-
} else if tstr == ~"s" {
320-
TyStr
321-
} else if tstr == ~"c" {
322-
TyChar
323-
} else if tstr == ~"d" || tstr == ~"i" {
324-
TyInt(Signed)
325-
} else if tstr == ~"u" {
326-
TyInt(Unsigned)
327-
} else if tstr == ~"x" {
328-
TyHex(CaseLower)
329-
} else if tstr == ~"X" {
330-
TyHex(CaseUpper)
331-
} else if tstr == ~"t" {
332-
TyBits
333-
} else if tstr == ~"o" {
334-
TyOctal
335-
} else if tstr == ~"f" {
336-
TyFloat
337-
} else if tstr == ~"?" {
338-
TyPoly
339-
} else { err(~"unknown type in conversion: " + tstr) };
340-
return Parsed::new(t, i + 1u);
315+
let t = match s[i] {
316+
'b' as u8 => TyBool,
317+
's' as u8 => TyStr,
318+
'c' as u8 => TyChar,
319+
'd' as u8 | 'i' as u8 => TyInt(Signed),
320+
'u' as u8 => TyInt(Unsigned),
321+
'x' as u8 => TyHex(CaseLower),
322+
'X' as u8 => TyHex(CaseUpper),
323+
't' as u8 => TyBits,
324+
'o' as u8 => TyOctal,
325+
'f' as u8 => TyFloat,
326+
'?' as u8 => TyPoly,
327+
_ => err(~"unknown type in conversion: " + s.substr(i, 1))
328+
};
329+
Parsed::new(t, i + 1)
341330
}
342331
}
343332

0 commit comments

Comments
 (0)