Static Public Member Functions | |
char[] | encode (wchar[] input, char[] output, inout uint consumed) |
wchar[] | decode (char[] input, wchar[] output, inout uint consumed) |
char[] | encode (wchar[] input) |
wchar[] | decode (char[] input) |
Static Private Member Functions | |
this () | |
Static Private Attributes | |
IOException | InvalidEncoding |
IOException | InvalidDecoding |
These routines were tuned on an Intel P3; other devices may work more efficiently with a slightly different approach, though this is likely to be reasonably optimal on AMD x86 CPUs also. These algorithms could benefit significantly from those extra AMD64 registers.
Note that foreach can produce noticeable more efficient code than equivalent for() loops, with either indices or pointers. The 0.98 compiler version exhibited some rather erratic behavior over the course of testing: in particular, elapsed time of method execution is noticeably dependent upon its physical location within the file (or, more specifically, the enclosing class). Yes, it sure sounds crazy that if you switch the order of encode() with decode() that they will consistently execute slower than as currently arranged.
Finally, please note that these are between 5 and 30 times faster than equivalent functions in the std.utf Phobos module (dependent upon the mix of char values). Those functions (strangely) often allocate memory on a character basis, so will become significantly slower where there's heap-contention by multiple threads.
Definition at line 73 of file Utf8.d.
|
Definition at line 82 of file Utf8.d. References InvalidDecoding, and InvalidEncoding. |
|
Encode UTF-8 up to a maximum of 3 bytes long (four, five & six byte variations are not supported). Throws an exception where the input wchar is greater than 0xd7ff. Definition at line 96 of file Utf8.d. References InvalidEncoding. Referenced by encode(). |
|
Decode UTF-8 produced by the above encode() method. This executes notably faster than the validating version. Definition at line 151 of file Utf8.d. References InvalidDecoding. Referenced by decode(). |
|
Encode UTF-8 up to a maximum of 3 bytes long (four, five & six byte variations are not supported). Throws an exception where the input wchar is greater than 0xd7ff. Definition at line 207 of file Utf8.d. References encode(). |
|
Decode UTF-8 produced by the above encode() method. This executes notably faster than the validating version. Definition at line 222 of file Utf8.d. References decode(). |
|
|
|
|