Skip to content

Commit 8c28cf7

Browse files
committed
---
yaml --- r: 44838 b: refs/heads/master c: 405a35c h: refs/heads/master v: v3
1 parent f5ba847 commit 8c28cf7

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5680ec027088c57f8b9fa3a9aa91daaf2428a57c
2+
refs/heads/master: 405a35c7f8cfaa9c77e71111a184e86d5ea4d637
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/src/libcore/num/strconv.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,17 +478,16 @@ pub pure fn from_str_bytes_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+
478478
}
479479
}
480480

481-
// XXX: Bytevector constant from str
482481
if special {
483-
if buf == str::to_bytes("inf") || buf == str::to_bytes("+inf") {
482+
if buf == str::inf_buf || buf == str::positive_inf_buf {
484483
return NumStrConv::inf();
485-
} else if buf == str::to_bytes("-inf") {
484+
} else if buf == str::negative_inf_buf {
486485
if negative {
487486
return NumStrConv::neg_inf();
488487
} else {
489488
return None;
490489
}
491-
} else if buf == str::to_bytes("NaN") {
490+
} else if buf == str::nan_buf {
492491
return NumStrConv::NaN();
493492
}
494493
}

trunk/src/libcore/str.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,13 @@ const tag_five_b: uint = 248u;
18321832
const max_five_b: uint = 67108864u;
18331833
const tag_six_b: uint = 252u;
18341834

1835+
// Constants used for converting strs to floats
1836+
pub const inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8];
1837+
pub const positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8,
1838+
'n' as u8, 'f' as u8];
1839+
pub const negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8,
1840+
'n' as u8, 'f' as u8];
1841+
pub const nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8];
18351842

18361843
/**
18371844
* Work with the byte buffer of a string.

0 commit comments

Comments
 (0)