[libcxx-commits] [libcxx] [libc++] Speed up classic locale (PR #72112)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 20 11:03:49 PST 2023
================
@@ -538,16 +549,40 @@ locale::__imp::use_facet(long id) const
// locale
+std::atomic<locale::__imp*> locale::__imp::classic_;
----------------
ldionne wrote:
Okay, sold. But even then, after the suggested refactoring we could do this:
```
const locale& locale::classic() {
static const no_destroy<locale> c(__private_tag{}, []{
__imp* ptr = &make<__imp>(1u);
// <comment ...>
classic_.store(ptr, std::memory_order_relaxed);
}());
return c.get();
}
```
I guess that makes this patch and the refactoring orthogonal.
https://github.com/llvm/llvm-project/pull/72112
More information about the libcxx-commits
mailing list