]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add comment to gslice::operator=(const gslice&) [PR100147]
authorJonathan Wakely <jwakely@redhat.com>
Sun, 4 Feb 2024 21:39:11 +0000 (21:39 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 8 Feb 2024 21:32:42 +0000 (21:32 +0000)
There's no need to check for self-assignment here, it would just add
extra code for an unlikely case. Add a comment saying so.

libstdc++-v3/ChangeLog:

PR libstdc++/100147
* include/bits/gslice.h (operator=): Add comment about lack of
self-assignment check.

libstdc++-v3/include/bits/gslice.h

index 3d78da2bd754a98344324289cd4e4334682ec49d..d9a8b929a5710d3dcec6d45caf86746f679f3c3a 100644 (file)
@@ -169,6 +169,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   inline gslice&
   gslice::operator=(const gslice& __g)
   {
+    // Safe for self-assignment. Checking for it would add overhead just to
+    // optimize a case that should never happen anyway.
     if (__g._M_index)
       __g._M_index->_M_increment_use();
     if (_M_index && _M_index->_M_decrement_use() == 0)