public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r14-8890] libstdc++: Add comment to gslice::operator=(const gslice&) [PR100147]
Date: Thu,  8 Feb 2024 21:49:10 +0000 (GMT)	[thread overview]
Message-ID: <20240208214910.39B493858C60@sourceware.org> (raw)

https://gcc.gnu.org/g:4e5dc6d9686a34d446147b923fe838389758a512

commit r14-8890-g4e5dc6d9686a34d446147b923fe838389758a512
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sun Feb 4 21:39:11 2024 +0000

    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:
---
 libstdc++-v3/include/bits/gslice.h | 2 ++
 1 file changed, 2 insertions(+)

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)

                 reply	other threads:[~2024-02-08 21:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240208214910.39B493858C60@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).