utf8 <-> utf16: codecvt poor performance

后端 未结 2 1871
自闭症患者
自闭症患者 2021-02-20 01:16

I\'m looking onto some of my old (and exclusively win32 oriented) stuff and thinking about making it more modern/portable - i.e. reimplementing some widely reusable parts in C++

2条回答
  •  走了就别回头了
    2021-02-20 02:00

    Win32's UTF8 transcode since Vista uses SSE internally to great effect, something very few other UTF transcoders do. I suspect it will be impossible to beat with even the most highly optimized portable code.

    However, this number you've given for codecvt is simply exceptionally slow if it's taking over 10x the time, and suggests a naive implementation. While writing my own UTF-8 decoder, I was able to reach within 2-3x the perf of Win32. There's a lot of room for improvement here, but you'd need to custom implement a codecvt to get it.

提交回复
热议问题