public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] libstdc++: Micro-optimizaion for std::bitset stream extraction
@ 2022-09-23 14:15 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-09-23 14:15 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Tested x86_64-linux, pushed to trunk.

-- >8 --

Don't bother trying to copy any characters for bitset<0>.

libstdc++-v3/ChangeLog:

	* include/std/bitset (operator>>): Do not copy for N==0.
	* testsuite/20_util/bitset/io/input.cc: Add comment.
---
 libstdc++-v3/include/std/bitset                   | 2 +-
 libstdc++-v3/testsuite/20_util/bitset/io/input.cc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index 83c6416b770..6dbc58c6429 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -1615,7 +1615,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
       if (__tmp.empty() && _Nb)
 	__state |= __ios_base::failbit;
-      else
+      else if _GLIBCXX17_CONSTEXPR (_Nb)
 	__x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb,
 				__zero, __one);
       if (__state)
diff --git a/libstdc++-v3/testsuite/20_util/bitset/io/input.cc b/libstdc++-v3/testsuite/20_util/bitset/io/input.cc
index 939861b171e..0f22cefbb5b 100644
--- a/libstdc++-v3/testsuite/20_util/bitset/io/input.cc
+++ b/libstdc++-v3/testsuite/20_util/bitset/io/input.cc
@@ -39,7 +39,7 @@ void test01()
   ss.clear();
   ss.str("*");
   ss >> b0;
-  VERIFY( ss.rdstate() == ios_base::goodbit );
+  VERIFY( ss.rdstate() == ios_base::goodbit ); // LWG 3199
 }
 
 int main()
-- 
2.37.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-23 14:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 14:15 [committed] libstdc++: Micro-optimizaion for std::bitset stream extraction Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).