I am working on a program that uses wcwidth from gnulib on many characters in a buffer, however this is reported to be slow under some platforms.[1]
The reason appears to be the call to locale_charset within the wcwidth implementation. I found some discussion of speeding this up in the bug-gnulib archives [2][3], has there been any progress on this? The charset could be cached either in wcwidth itself, or there could be some caching in locale_charset. It appears you can have thread-local variables with gcc using "__thread", for example, "static __thread const char *encoding". (I don't know about other compilers.) Would something like this work? As well as threads, updating the cached encoding when the encoding changes would be a problem. [1] http://lists.gnu.org/archive/html/bug-texinfo/2015-01/msg00004.html [2] http://lists.gnu.org/archive/html/bug-gnulib/2011-12/msg00083.html [3] http://lists.gnu.org/archive/html/bug-gnulib/2013-12/msg00087.html