[libcxx-commits] [libcxx] [libcxx] Speed up xsgetn for always_noconv (PR #212010)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 23 02:20:52 PDT 2026


================
@@ -199,6 +200,28 @@ typename __stdinbuf<_CharT>::int_type __stdinbuf<_CharT>::__getchar(bool __consu
   return traits_type::to_int_type(__1buf);
 }
 
+template <class _CharT>
+streamsize __stdinbuf<_CharT>::xsgetn(char_type* __s, streamsize __n) {
+  if constexpr (is_same<_CharT, char>::value) {
+    if (__always_noconv_) {
+      streamsize __i = 0;
+      if (__i < __n && __last_consumed_is_next_) {
+        __s[__i++]               = traits_type::to_char_type(__last_consumed_);
----------------
philnik777 wrote:

Oops, yeah, I was thinking of `xsputn`. `xsgetn` obviously has to modify the buffer.

https://github.com/llvm/llvm-project/pull/212010


More information about the libcxx-commits mailing list