Optimize `ToUTF8::Utf8Encoder::getLength` and `ToUTF8::Utf8Encoder::getUtf8`
Currently, those two functions take around 8% of the CPU time when running ./esmtool dump -q -p -C ~/.local/share/openmw/basedata/TR_Mainland.esm
, and could easily be optimized/refactored.
Benchmark/tracing can be done like this on Linux, with hotspot and perf :
$ perf record --call-graph dwarf --aio ./esmtool dump -q -p -C ~/.local/share/openmw/basedata/TR_Mainland.esm
$ hotspot ./perf.data
Be mindful that some localized versions of Morrowind, like Russian, are heavy on utf8 ;)
This is especially useful for fuzzing.