diff options
| author | Eugen Wissner <belka@caraus.de> | 2017-08-22 12:47:13 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2017-08-22 12:47:13 +0200 |
| commit | 0f1e53b4b9587b6dd257fafa92e4dbb269f89188 (patch) | |
| tree | 959fd16e810a35c7e3e9521cf84f4cc3e780126e | |
| parent | 666d59c231f2aea29108db07c981664329a314e8 (diff) | |
| download | tanya-0f1e53b4b9587b6dd257fafa92e4dbb269f89188.tar.gz | |
format.conv: Replace loop with copy()
| -rw-r--r-- | source/tanya/format/conv.d | 24 |
1 files 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]; } |
