[PATCH] libstdc++: Use string::push_back instead of string::operator+=
Aditya K
hiraditya@msn.com
Thu Jan 16 20:00:26 GMT 2025
>> From db5036e40ed7ac43b66ca74c44ec8d0bdc934b07 Mon Sep 17 00:00:00 2001
>> From: AdityaK <110843012+@users.noreply.github.com<mailto:110843012+@users.noreply.github.com>>
>> Date: Sun, 29 Dec 2024 18:14:29 -0800
>> Subject: [PATCH] libstdc++: Use string::push_back instead of string::operator+=
>>
>> operator+= returns string& which is ignored anyways.
>Why does this matter? The compiler can see that the return value isn't used.
>Using += seems more readable to me.
nvm, i see both produce the same code. sorry for the noise.
________________________________
From: Aditya K <hiraditya@msn.com>
Sent: Tuesday, January 14, 2025 12:05 PM
To: gcc-patches@gcc.gnu.org <gcc-patches@gcc.gnu.org>; libstdc++@gcc.gnu.org <libstdc++@gcc.gnu.org>
Cc: jwakely@redhat.com <jwakely@redhat.com>
Subject: Re: [PATCH] libstdc++: Use string::push_back instead of string::operator+=
pinging in case this was missed.
________________________________
From: Aditya K <hiraditya@msn.com>
Sent: Sunday, December 29, 2024 6:36 PM
To: gcc-patches@gcc.gnu.org <gcc-patches@gcc.gnu.org>; libstdc++@gcc.gnu.org <libstdc++@gcc.gnu.org>
Cc: jwakely@redhat.com <jwakely@redhat.com>
Subject: [PATCH] libstdc++: Use string::push_back instead of string::operator+=
>From db5036e40ed7ac43b66ca74c44ec8d0bdc934b07 Mon Sep 17 00:00:00 2001
From: AdityaK <110843012+@users.noreply.github.com>
Date: Sun, 29 Dec 2024 18:14:29 -0800
Subject: [PATCH] libstdc++: Use string::push_back instead of string::operator+=
operator+= returns string& which is ignored anyways.
---
libstdc++-v3/ChangeLog | 5 +++++
libstdc++-v3/include/bits/basic_string.tcc | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 9ab5eeb55a5..be90bfd47e8 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2024-12-29 Aditya Kumar <hiraditya@msn.com>
+ * include/bits/basic_string.tcc (getline): Use string::push_back
+ instead of string::operator+=
+
+
2024-12-29 Gerald Pfeifer <gerald@pfeifer.com>
* doc/html/manual/profile_mode_diagnostics.html: Delete.
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index caeddaf2f5b..ddb41c8e7e2 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -935,7 +935,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
&& !_Traits::eq_int_type(__c, __eof)
&& !_Traits::eq_int_type(__c, __idelim))
{
- __str += _Traits::to_char_type(__c);
+ __str.push_back(_Traits::to_char_type(__c));
++__extracted;
__c = __in.rdbuf()->snextc();
}
--
2.47.1.613.gc27f4b7a9f-goog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20250116/5c7831a4/attachment.htm>
More information about the Libstdc++
mailing list