about summary refs log tree commit diff
path: root/src/libstd/num/float.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-06-28 14:05:10 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-06-30 09:19:25 -0700
commitd3155faedee97cb916735573fbf067d6305ee730 (patch)
treec7fe8365b82802cb8c634500f6444896014e0286 /src/libstd/num/float.rs
parent8fe6fc11de4d6bfbffd8b961f5f1f24a338601d5 (diff)
downloadrust-d3155faedee97cb916735573fbf067d6305ee730.tar.gz
rust-d3155faedee97cb916735573fbf067d6305ee730.zip
Specialize to_str_common for floats/integers in strconv
This allows the integral paths to avoid allocations on the heap

Closes #4424, #4423
Diffstat (limited to 'src/libstd/num/float.rs')
-rw-r--r--src/libstd/num/float.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/libstd/num/float.rs b/src/libstd/num/float.rs
index c583aeacf16..7a6e3042e7b 100644
--- a/src/libstd/num/float.rs
+++ b/src/libstd/num/float.rs
@@ -101,8 +101,8 @@ pub mod consts {
 ///
 #[inline]
 pub fn to_str(num: float) -> ~str {
-    let (r, _) = strconv::to_str_common(
-        &num, 10u, true, strconv::SignNeg, strconv::DigAll);
+    let (r, _) = strconv::float_to_str_common(
+        num, 10u, true, strconv::SignNeg, strconv::DigAll);
     r
 }
 
@@ -115,8 +115,8 @@ pub fn to_str(num: float) -> ~str {
 ///
 #[inline]
 pub fn to_str_hex(num: float) -> ~str {
-    let (r, _) = strconv::to_str_common(
-        &num, 16u, true, strconv::SignNeg, strconv::DigAll);
+    let (r, _) = strconv::float_to_str_common(
+        num, 16u, true, strconv::SignNeg, strconv::DigAll);
     r
 }
 
@@ -136,8 +136,8 @@ pub fn to_str_hex(num: float) -> ~str {
 ///
 #[inline]
 pub fn to_str_radix(num: float, radix: uint) -> ~str {
-    let (r, special) = strconv::to_str_common(
-        &num, radix, true, strconv::SignNeg, strconv::DigAll);
+    let (r, special) = strconv::float_to_str_common(
+        num, radix, true, strconv::SignNeg, strconv::DigAll);
     if special { fail!("number has a special value, \
                          try to_str_radix_special() if those are expected") }
     r
@@ -154,7 +154,7 @@ pub fn to_str_radix(num: float, radix: uint) -> ~str {
 ///
 #[inline]
 pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) {
-    strconv::to_str_common(&num, radix, true,
+    strconv::float_to_str_common(num, radix, true,
                            strconv::SignNeg, strconv::DigAll)
 }
 
@@ -169,8 +169,8 @@ pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) {
 ///
 #[inline]
 pub fn to_str_exact(num: float, digits: uint) -> ~str {
-    let (r, _) = strconv::to_str_common(
-        &num, 10u, true, strconv::SignNeg, strconv::DigExact(digits));
+    let (r, _) = strconv::float_to_str_common(
+        num, 10u, true, strconv::SignNeg, strconv::DigExact(digits));
     r
 }
 
@@ -185,8 +185,8 @@ pub fn to_str_exact(num: float, digits: uint) -> ~str {
 ///
 #[inline]
 pub fn to_str_digits(num: float, digits: uint) -> ~str {
-    let (r, _) = strconv::to_str_common(
-        &num, 10u, true, strconv::SignNeg, strconv::DigMax(digits));
+    let (r, _) = strconv::float_to_str_common(
+        num, 10u, true, strconv::SignNeg, strconv::DigMax(digits));
     r
 }