From: Jonathan Wakely Date: Sun, 4 Feb 2024 21:39:11 +0000 (+0000) Subject: libstdc++: Add comment to gslice::operator=(const gslice&) [PR100147] X-Git-Tag: basepoints/gcc-15~1249 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e5dc6d9686a34d446147b923fe838389758a512;p=thirdparty%2Fgcc.git libstdc++: Add comment to gslice::operator=(const gslice&) [PR100147] 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. --- diff --git a/libstdc++-v3/include/bits/gslice.h b/libstdc++-v3/include/bits/gslice.h index 3d78da2bd754..d9a8b929a571 100644 --- a/libstdc++-v3/include/bits/gslice.h +++ b/libstdc++-v3/include/bits/gslice.h @@ -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)