Bug 3758 – Create D impementation of to!(float, string), etc.
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-01-31T08:14:00Z
Last change time
2015-06-09T01:27:39Z
Keywords
performance
Assigned to
nobody
Creator
dsimcha
Comments
Comment #0 by dsimcha — 2010-01-31T08:14:15Z
std.conv calls the c functions atof, atod, atold, etc. for to!(float, string), to!(double, string), and to!(real, string) respectively. There are two practical reasons why we need D implementations of these functions:
1. Strings should be convertible to floats at compile time.
2. To make the input string compatible with C, it is copied using toStringz. This is inefficient, especially when trying to real large files with ASCII numbers in and convert the ASCII numbers to floats.
Comment #1 by dsimcha — 2010-08-15T21:27:38Z
A D implementation that doesn't allocate on every conversion now exists, even though it still doesn't work at compile time. Since converting strings to floats at compile time isn't very useful in practice anyhow, and I cared more about the memory allocations when I initially filed this, I'll mark it as resolved.