This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] regex_traits implementation
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: Tim Shen <timshen91 at gmail dot com>, "libstdc++" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Stephen Webb <stephen dot webb at canonical dot com>
- Date: Tue, 2 Jul 2013 21:42:47 +0100
- Subject: Re: [patch] regex_traits implementation
- References: <CAPrifDmvwyXmOS4Wp1mo+ORnEk0o5=_dXbLimv9soahjcSuwAw at mail dot gmail dot com> <51CE1755 dot 1040401 at oracle dot com> <51CE1ED5 dot 6020104 at bregmasoft dot ca> <294c5ce0-0569-463f-b716-95abf2d2f848 at email dot android dot com> <CAGBC11ktNNzXhMLPuoxwyQ0o2QqEtq0S8Qi8YN3FMSsh5r_rZA at mail dot gmail dot com> <CAGBC11mJEnp70OdDdKr9BduhxXCrs9RUoN0TOXKhg7VSKnvQMQ at mail dot gmail dot com> <CAH6eHdShjBcZ+yF8O3+SOh222G5BQ5huMyE7-i0OhCTmbBhoeQ at mail dot gmail dot com> <CAPrifDnC--3U0KMW6DPZa_TCN=JAUrxLu3u-uTSihHPD_Hv_sg at mail dot gmail dot com> <fa4b166c-3277-43b0-ad44-6e5a6809d7cd at email dot android dot com>
On 2 July 2013 20:27, Paolo Carlini wrote:
>
>
> Hi,
>
>>Second, making it `const` enables more potential compiler
>>optimizations.
>
> Stylistically, we already discussed this in the past and the outcome was that normally we don't use const by value anywhere. But personally I don't have a strong opinion and certainly I would not object if it makes a difference from the optimization point of view: as far as I know it does *not*, like it does not declaring const a local, do you have some up to date evidence that it does?
It doesn't make any difference. The compiler knows that the object
isn't modified and is a function parameter so cannot be aliased, so
making it const makes no difference at all.