From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 6DCF3385DC3B; Thu, 17 Aug 2023 20:31:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DCF3385DC3B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692304287; bh=na0VParpgZ6BekeVAssu7r5QWugJpIVKpkCw347Rj1Q=; h=From:To:Subject:Date:From; b=Vhl9pzc37Hw42FEZIU3CFk9fbFPjUZtflGmfudhWmBqDSQXBkO6JDF9clMOEKB153 9ONOXej9Fuw2pthqdwxeLMOHIuWenLtiNpFlUo3C9DdrAPIsubJZkRweuPPNJUPmS/ 0PqpkLFQhw/tOMOeayCRGTxDhYqbbanlL8CfT+o0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-3308] libstdc++: Reuse double overload of __convert_to_v if possible X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 74c019b50b7724dd5ed7af640b6c0427383d48df X-Git-Newrev: aad83d61d2e92b168688f7b6bd00b8604d11fc9f Message-Id: <20230817203127.6DCF3385DC3B@sourceware.org> Date: Thu, 17 Aug 2023 20:31:27 +0000 (GMT) List-Id: https://gcc.gnu.org/g:aad83d61d2e92b168688f7b6bd00b8604d11fc9f commit r14-3308-gaad83d61d2e92b168688f7b6bd00b8604d11fc9f Author: Jonathan Wakely Date: Mon Jul 24 11:38:32 2023 +0100 libstdc++: Reuse double overload of __convert_to_v if possible For targets where double and long double have the same representation we can reuse the same __convert_to_v code for both types. This will slightly reduce the size of the compiled code in the library. libstdc++-v3/ChangeLog: * config/locale/generic/c_locale.cc (__convert_to_v): Reuse double overload for long double if possible. Diff: --- libstdc++-v3/config/locale/generic/c_locale.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc index 8849d78fdfac..866ba0361dc4 100644 --- a/libstdc++-v3/config/locale/generic/c_locale.cc +++ b/libstdc++-v3/config/locale/generic/c_locale.cc @@ -187,6 +187,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err, const __c_locale&) throw() { +#if __DBL_MANT_DIG__ == __LDBL_MANT_DIG__ + double __d; + __convert_to_v(__s, __d, __err, __c_locale); + __v = __d; +#else // Assumes __s formatted for "C" locale. const char* __sav = __set_C_locale(); if (!__sav) @@ -233,6 +238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION setlocale(LC_ALL, __sav); delete [] __sav; +#endif // __DBL_MANT_DIG__ == __LDBL_MANT_DIG__ } void