This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +0
-43
lines changed Expand file tree Collapse file tree 1 file changed +0
-43
lines changed Original file line number Diff line number Diff line change @@ -50,32 +50,6 @@ if (radix >= 2 && radix <= 16)
5050 return buf[i .. $];
5151}
5252
53- // TEMPORARY. Delete after the related Phobos PR is merged.
54- char [] unsignedToTempString ()(ulong value, return scope char [] buf, uint radix) @safe
55- {
56- if (radix < 2 )
57- // not a valid radix, just return an empty string
58- return buf[$ .. $];
59-
60- size_t i = buf.length;
61- do
62- {
63- if (value < radix)
64- {
65- ubyte x = cast (ubyte )value;
66- buf[-- i] = cast (char )((x < 10 ) ? x + ' 0' : x - 10 + ' a' );
67- break ;
68- }
69- else
70- {
71- ubyte x = cast (ubyte )(value % radix);
72- value = value / radix;
73- buf[-- i] = cast (char )((x < 10 ) ? x + ' 0' : x - 10 + ' a' );
74- }
75- } while (value);
76- return buf[i .. $];
77- }
78-
7953private struct TempStringNoAlloc ()
8054{
8155 // need to handle 65 bytes for radix of 2 with negative sign.
@@ -164,23 +138,6 @@ auto signedToTempString(uint radix = 10)(long value) @safe
164138 return r;
165139}
166140
167- // TEMPORARY. Delete after the related Phobos PR is merged.
168- char [] signedToTempString ()(long value, return scope char [] buf, uint radix) @safe
169- {
170- bool neg = value < 0 ;
171- if (neg)
172- value = cast (ulong )- value;
173- auto r = unsignedToTempString(value, buf, radix);
174- if (neg)
175- {
176- // about to do a slice without a bounds check
177- auto trustedSlice (return char [] r) @trusted { assert (r.ptr > buf.ptr); return (r.ptr- 1 )[0 .. r.length+ 1 ]; }
178- r = trustedSlice(r);
179- r[0 ] = ' -' ;
180- }
181- return r;
182- }
183-
184141unittest
185142{
186143 SignedStringBuf buf;
You can’t perform that action at this time.
0 commit comments