about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-03-01 08:44:47 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-03-01 08:44:47 -0800
commit50c08dbf0d0150de41fcc7f5e87a97c4ea2bd4f0 (patch)
treeb5c0934d19eccfef2efaf61008320b1924224a45 /src
parent02a4b5bed33636d5a8e26cf9e3a225b42f5f4625 (diff)
parent405a35c7f8cfaa9c77e71111a184e86d5ea4d637 (diff)
downloadrust-50c08dbf0d0150de41fcc7f5e87a97c4ea2bd4f0.tar.gz
rust-50c08dbf0d0150de41fcc7f5e87a97c4ea2bd4f0.zip
Merge pull request #5178 from catamorphism/constant-buffers
core: Address XXX, make static constants for strings used when stringify...
Diffstat (limited to 'src')
-rw-r--r--src/libcore/num/strconv.rs7
-rw-r--r--src/libcore/str.rs7
2 files changed, 10 insertions, 4 deletions
diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs
index 4322ea40428..50fc1b03ccc 100644
--- a/src/libcore/num/strconv.rs
+++ b/src/libcore/num/strconv.rs
@@ -478,17 +478,16 @@ pub pure fn from_str_bytes_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+
         }
     }
 
-    // XXX: Bytevector constant from str
     if special {
-        if buf == str::to_bytes("inf") || buf == str::to_bytes("+inf") {
+        if buf == str::inf_buf || buf == str::positive_inf_buf {
             return NumStrConv::inf();
-        } else if buf == str::to_bytes("-inf") {
+        } else if buf == str::negative_inf_buf {
             if negative {
                 return NumStrConv::neg_inf();
             } else {
                 return None;
             }
-        } else if buf == str::to_bytes("NaN") {
+        } else if buf == str::nan_buf {
             return NumStrConv::NaN();
         }
     }
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 6ee6d282841..7dfc52c458a 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -1832,6 +1832,13 @@ const tag_five_b: uint = 248u;
 const max_five_b: uint = 67108864u;
 const tag_six_b: uint = 252u;
 
+// Constants used for converting strs to floats
+pub const inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8];
+pub const positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8,
+                                      'n' as u8, 'f' as u8];
+pub const negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8,
+                                      'n' as u8, 'f' as u8];
+pub const nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8];
 
 /**
  * Work with the byte buffer of a string.