Inheritance diagram for TranscoderUtf8:
Public Member Functions | |
char[] | toString () |
char[] | encode (dchar[] input, char[] output, out uint consumed) |
dchar[] | decode (char[] input, dchar[] output, out uint consumed) |
Private Member Functions | |
void | fault (char[] msg) |
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 70 of file Utf8.d.
|
Return the encoding name of this transcoder Reimplemented from Transcoder. |
|
Encode UTF-8 up to a maximum of 4 bytes long (five & six byte variations are not supported). Throws an exception where the input dchar is greater than 0x10ffff. Reimplemented from Transcoder. Definition at line 89 of file Utf8.d. References Transcoder::fault(). |
|
Decode UTF-8 produced by the above encode() method. This executes notably faster than the validating version. Reimplemented from Transcoder. Reimplemented in TranscoderUtf8Checked. |
|
overridable exception thrower Definition at line 78 of file Transcoder.d. References Exception. Referenced by TranscoderUtf8Checked::decode(), encode(), and TranscoderIso8859_1::encode(). |