From 0f1e53b4b9587b6dd257fafa92e4dbb269f89188 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 22 Aug 2017 12:47:13 +0200 Subject: [PATCH] format.conv: Replace loop with copy() --- source/tanya/format/conv.d | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/source/tanya/format/conv.d b/source/tanya/format/conv.d index fe0998d..82bcada 100644 --- a/source/tanya/format/conv.d +++ b/source/tanya/format/conv.d @@ -17,6 +17,7 @@ module tanya.format.conv; import std.traits; import tanya.container.string; import tanya.memory; +import tanya.memory.op; /** * Thrown if a type conversion fails. @@ -669,32 +670,17 @@ package char[] number2String(T)(const T number, char[] buffer) // Write the string. char* bp = buffer.ptr; - // Set sign. + // Set the sign. if (number < 0) { *bp++ = '-'; } // Copy the string into the target buffer. - uint n = l; - while (n) - { - int i = n; - n -= i; + int i = l; + copy(start[0 .. l], bp[0 .. l]); + bp += l; - while (i >= 4) - { - *cast(uint*) bp = *cast(uint*) start; - bp += 4; - start += 4; - i -= 4; - } - while (i) - { - *bp++ = *start++; - --i; - } - } return buffer[0 .. bp - buffer.ptr]; }