@@ -310,34 +310,23 @@ pub mod ct {
310
310
pub fn parse_type( s : & str , i : uint , lim : uint , err : ErrorFn ) ->
311
311
Parsed < Ty > {
312
312
if i >= lim { err ( ~"missing type in conversion") ; }
313
- let tstr = str:: slice ( s, i, i+1 u) ;
314
313
// FIXME (#2249): Do we really want two signed types here?
315
314
// 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)
341
330
}
342
331
}
343
332
0 commit comments