[PATCH] libstdc++: Use string::push_back instead of string::operator+=
Jonathan Wakely
jwakely@redhat.com
Wed Jan 15 10:54:31 GMT 2025
On Mon, 30 Dec 2024 at 02:37, Aditya K <hiraditya@msn.com> wrote:
>
> 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.
Why does this matter? The compiler can see that the return value isn't used.
Using += seems more readable to me.
> ---
> 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+=
> +
> +
The ChangeLog file is automatically updated every night based on the
commits to Git, please don't patch it (this has been the case for many
years).
> 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
>
>
>
More information about the Libstdc++
mailing list