Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Remove old (n)signedToTempString functions
Browse files Browse the repository at this point in the history
  • Loading branch information
andralex authored and dlang-bot committed Jul 27, 2020
1 parent d55088a commit 104ac71
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions src/core/internal/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,6 @@ if (radix >= 2 && radix <= 16)
return buf[i .. $];
}

// TEMPORARY. Delete after the related Phobos PR is merged.
char[] unsignedToTempString()(ulong value, return scope char[] buf, uint radix) @safe
{
if (radix < 2)
// not a valid radix, just return an empty string
return buf[$ .. $];

size_t i = buf.length;
do
{
if (value < radix)
{
ubyte x = cast(ubyte)value;
buf[--i] = cast(char)((x < 10) ? x + '0' : x - 10 + 'a');
break;
}
else
{
ubyte x = cast(ubyte)(value % radix);
value = value / radix;
buf[--i] = cast(char)((x < 10) ? x + '0' : x - 10 + 'a');
}
} while (value);
return buf[i .. $];
}

private struct TempStringNoAlloc()
{
// need to handle 65 bytes for radix of 2 with negative sign.
Expand Down Expand Up @@ -164,23 +138,6 @@ auto signedToTempString(uint radix = 10)(long value) @safe
return r;
}

// TEMPORARY. Delete after the related Phobos PR is merged.
char[] signedToTempString()(long value, return scope char[] buf, uint radix) @safe
{
bool neg = value < 0;
if (neg)
value = cast(ulong)-value;
auto r = unsignedToTempString(value, buf, radix);
if (neg)
{
// about to do a slice without a bounds check
auto trustedSlice(return char[] r) @trusted { assert(r.ptr > buf.ptr); return (r.ptr-1)[0..r.length+1]; }
r = trustedSlice(r);
r[0] = '-';
}
return r;
}

unittest
{
SignedStringBuf buf;
Expand Down

0 comments on commit 104ac71

Please sign in to comment.