[libcxx-commits] [libcxx] a9407d5 - [libc++] Port #200996 to ostream (#226372)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Sep 27 07:41:34 PDT 2026
Author: Nico Weber
Date: 2026-09-27T07:41:26-07:00
New Revision: a9407d59c4abfb8bf49da7dfcec6775707288b9e
URL: https://github.com/llvm/llvm-project/commit/a9407d59c4abfb8bf49da7dfcec6775707288b9e
DIFF: https://github.com/llvm/llvm-project/commit/a9407d59c4abfb8bf49da7dfcec6775707288b9e.diff
LOG: [libc++] Port #200996 to ostream (#226372)
Reduces the time to compile a TU with just `#include <ostream>` from
254.7 ms ± 3.0 ms to 227.7 ms ± 2.1 ms on my system (-std=c++23, -O2,
arm64 macOS).
See #195466 for details. Without this, the call is evaluated when the
template is parsed, which evaluates format_string's consteval
constructor for "\n" in every translation unit that includes <ostream>,
even if nothing calls println().
No behavior change.
Added:
Modified:
libcxx/include/__ostream/print.h
Removed:
################################################################################
diff --git a/libcxx/include/__ostream/print.h b/libcxx/include/__ostream/print.h
index 4a519c177b990..f9810a4d7d26a 100644
--- a/libcxx/include/__ostream/print.h
+++ b/libcxx/include/__ostream/print.h
@@ -159,9 +159,9 @@ _LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt,
# endif // _LIBCPP_HAS_UNICODE
}
-template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
+template <class _Void = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
_LIBCPP_HIDE_FROM_ABI inline void println(ostream& __os) {
- std::print(__os, "\n");
+ std::print(__os, (_Void(), "\n"));
}
# endif // _LIBCPP_STD_VER >= 23
More information about the libcxx-commits
mailing list