[libcxx-commits] [libcxx] [libc++] Speed up classic locale (PR #72112)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 23 14:23:39 PST 2023
================
@@ -14,17 +15,73 @@ double istream_numbers() {
double f1 = 0.0, f2 = 0.0, q = 0.0;
for (int i = 0; i < 3; i++) {
std::istringstream s(a[i]);
+ if (loc)
+ s.imbue(*loc);
s >> a1 >> a2 >> a3 >> f1 >> a4 >> a5 >> f2 >> a6 >> a7;
q += (a1 + a2 + a3 + a4 + a5 + a6 + a7 + f1 + f2) / 1000000;
}
return q;
}
+struct LocaleSelector {
+ std::locale* imbue;
+ std::locale old;
+ static std::mutex mutex;
----------------
ldionne wrote:
@dvyukov Can you confirm that this mutex should be global to the class? Previously you were creating a function-local static mutex inside the constructor and one inside the destructor, which seemed wrong.
https://github.com/llvm/llvm-project/pull/72112
More information about the libcxx-commits
mailing list