Re: uc_width and wcwidth optimization

2018-05-22 Thread Alexander Lukyanov
Cool! I'm glad my work was useful after all. пн, 21 мая 2018 г. в 13:04, Bruno Haible : > Alexander V. Lukyanov wrote in > : > > For quite some time I use this locale_charset optimization, which uses > > binary search for locale

Re: uc_width and wcwidth optimization

2018-05-21 Thread Bruno Haible
Alexander V. Lukyanov wrote in : > For quite some time I use this locale_charset optimization, which uses > binary search for locale alias resolution. This is a good optimization. I ended up implementing a binary search as well, a

Re: uc_width and wcwidth optimization

2013-12-13 Thread Alexander V. Lukyanov
On 12/13/2011 11:32 AM, Bruno Haible wrote: > I would love to have locale_charset be either faster or use some thread-safe > cache. Do you have an idea how to realize this? For quite some time I use this locale_charset optimization, which uses binary search for locale alias resolution. -- Ale

Re: uc_width and wcwidth optimization

2011-12-15 Thread Paolo Bonzini
On 12/13/2011 11:32 AM, Bruno Haible wrote: I'm attaching the benchmark program I'm experimenting with. So far, it seems that locale_charset() is really slow, whereas the is_cjk stuff is not a big speed problem. I would love to have locale_charset be either faster or use some thread-safe cache.

Re: uc_width and wcwidth optimization

2011-12-15 Thread Alexander V. Lukyanov
Here is another patch which changes linear search to bsearch. With charset aliases of DARWIN7 case I get 10 times reduction of benchmark execution time. This patch should be thread-safe, in worst case it would leak some memory _once_ (just as before). -- Alexander. diff --git a/lib/localchar

Re: uc_width and wcwidth optimization

2011-12-14 Thread Alexander V. Lukyanov
On Wed, Dec 14, 2011 at 02:02:33PM +0400, Alexander V. Lukyanov wrote: > It means that it is possible to avoid is_cjk_encoding() calling at all, > because uc_width only uses encoding for cjk checking and uc_width is only > called by wcwidth for UTF-8 case (which is not a cjk encoding). Here is a p

Re: uc_width and wcwidth optimization

2011-12-14 Thread Alexander V. Lukyanov
On Wed, Dec 14, 2011 at 02:02:33PM +0400, Alexander V. Lukyanov wrote: > is_cjk_encoding() is on the second place after locale_charset. * Only in certain cases. -- Alexander.

Re: uc_width and wcwidth optimization

2011-12-14 Thread Alexander V. Lukyanov
On Wed, Dec 14, 2011 at 02:06:45PM +0400, Alexander V. Lukyanov wrote: > On Tue, Dec 13, 2011 at 11:32:53AM +0100, Bruno Haible wrote: > > I would love to have locale_charset be either faster or use some thread-safe > > cache. Do you have an idea how to realize this? > > BTW, is it possible to hoo

Re: uc_width and wcwidth optimization

2011-12-14 Thread Alexander V. Lukyanov
On Tue, Dec 13, 2011 at 11:32:53AM +0100, Bruno Haible wrote: > 2) The wcwidth change is a good idea, but unfortunately is not multithread- > safe. Different threads can have different locales, therefore a global > variable as a cache won't lead to correct results always. Fortunately c

Re: uc_width and wcwidth optimization

2011-12-14 Thread Alexander V. Lukyanov
On Tue, Dec 13, 2011 at 11:32:53AM +0100, Bruno Haible wrote: > I would love to have locale_charset be either faster or use some thread-safe > cache. Do you have an idea how to realize this? BTW, is it possible to hook setlocale call to reset or disable the cache? E.g. save thread-id with the cac

Re: uc_width and wcwidth optimization

2011-12-13 Thread Bruno Haible
Hello, Alexander V. Lukyanov wrote: > Attached is the patch to optimize performance of wcwith, uc_width and > uc{8,16,32}_width functions. > > The optimization is caching of is_cjk_encoding() and using > nl_langinfo(CODESET) before the complex locale_charset() to check if the > charset has change