Skip to content

Commit 624a685

Browse files
committed
Moved float str buffer constants to the strconv module
1 parent 51eb7dc commit 624a685

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/libcore/num/strconv.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ impl_NumStrConv_Integer!(u16)
130130
impl_NumStrConv_Integer!(u32)
131131
impl_NumStrConv_Integer!(u64)
132132

133+
134+
// Special value strings as [u8] consts.
135+
const inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8];
136+
const positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8, 'n' as u8, 'f' as u8];
137+
const negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8, 'n' as u8, 'f' as u8];
138+
const nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8];
139+
133140
/**
134141
* Converts a number to its string representation as a byte vector.
135142
* This is meant to be a common base implementation for all numeric string
@@ -479,15 +486,15 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+
479486
}
480487

481488
if special {
482-
if buf == str::inf_buf || buf == str::positive_inf_buf {
489+
if buf == inf_buf || buf == positive_inf_buf {
483490
return NumStrConv::inf();
484-
} else if buf == str::negative_inf_buf {
491+
} else if buf == negative_inf_buf {
485492
if negative {
486493
return NumStrConv::neg_inf();
487494
} else {
488495
return None;
489496
}
490-
} else if buf == str::nan_buf {
497+
} else if buf == nan_buf {
491498
return NumStrConv::NaN();
492499
}
493500
}

src/libcore/str.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,14 +1919,6 @@ static tag_five_b: uint = 248u;
19191919
static max_five_b: uint = 67108864u;
19201920
static tag_six_b: uint = 252u;
19211921

1922-
// Constants used for converting strs to floats
1923-
pub static inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8];
1924-
pub static positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8,
1925-
'n' as u8, 'f' as u8];
1926-
pub static negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8,
1927-
'n' as u8, 'f' as u8];
1928-
pub static nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8];
1929-
19301922
/**
19311923
* Work with the byte buffer of a string.
19321924
*

0 commit comments

Comments
 (0)