From 624a685283f66afcb40ee3c235624aedebc2f08f Mon Sep 17 00:00:00 2001 From: Marvin Löbel Date: Fri, 22 Mar 2013 02:04:13 +0100 Subject: Moved float str buffer constants to the strconv module --- src/libcore/num/strconv.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/libcore/num') diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs index 26f0582bfb2..e73a4a2ccaa 100644 --- a/src/libcore/num/strconv.rs +++ b/src/libcore/num/strconv.rs @@ -130,6 +130,13 @@ impl_NumStrConv_Integer!(u16) impl_NumStrConv_Integer!(u32) impl_NumStrConv_Integer!(u64) + +// Special value strings as [u8] consts. +const inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8]; +const positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8, 'n' as u8, 'f' as u8]; +const negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8, 'n' as u8, 'f' as u8]; +const nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8]; + /** * Converts a number to its string representation as a byte vector. * This is meant to be a common base implementation for all numeric string @@ -479,15 +486,15 @@ pub fn from_str_bytes_common+ } if special { - if buf == str::inf_buf || buf == str::positive_inf_buf { + if buf == inf_buf || buf == positive_inf_buf { return NumStrConv::inf(); - } else if buf == str::negative_inf_buf { + } else if buf == negative_inf_buf { if negative { return NumStrConv::neg_inf(); } else { return None; } - } else if buf == str::nan_buf { + } else if buf == nan_buf { return NumStrConv::NaN(); } } -- cgit 1.4.1-3-g733a5