Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Issue 3186017: Don't use const char kFoo[] in the stack place. (Closed)

Created:
10 years, 4 months ago by tfarina
Modified:
9 years, 7 months ago
CC:
chromium-reviews, brettw-cc_chromium.org, Paweł Hajdan Jr.
Base URL:
http://src.chromium.org/git/chromium.git
Visibility:
Public.

Description

Don't use const char kFoo[] in the stack place. It creates a variable and copy the value all around. Instead use pointer so the other places where the variable is used just point to the orignal variable instead of copying the value. BUG=None TEST=out/Debug/base_unittests --gtest_filter=EnvironmentTest.* Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=56802

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+4 lines, -4 lines) Patch
M base/environment_unittest.cc View 2 chunks +4 lines, -4 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
tfarina
10 years, 4 months ago (2010-08-19 18:25:19 UTC) #1
M-A Ruel
lgtm
10 years, 4 months ago (2010-08-19 18:36:29 UTC) #2
willchan_google.com
Drive-by: On Thu, Aug 19, 2010 at 11:25 AM, <tfarina@chromium.org> wrote: > Reviewers: Marc-Antoine Ruel, ...
10 years, 4 months ago (2010-08-19 18:47:20 UTC) #3
M-A Ruel
On 2010/08/19 18:47:20, willchan_google.com wrote: > Drive-by: > > On Thu, Aug 19, 2010 at ...
10 years, 4 months ago (2010-08-19 18:52:40 UTC) #4
willchan no longer on Chromium
On 2010/08/19 18:52:40, Marc-Antoine Ruel wrote: > On 2010/08/19 18:47:20, http://willchan_google.com wrote: > > Drive-by: ...
10 years, 4 months ago (2010-08-19 18:59:16 UTC) #5
M-A Ruel
10 years, 4 months ago (2010-08-19 19:10:48 UTC) #6
On 2010/08/19 18:59:16, willchan wrote:
> On 2010/08/19 18:52:40, Marc-Antoine Ruel wrote:
> > On 2010/08/19 18:47:20, http://willchan_google.com wrote:
> > By style guide, const local variables aren't encouraged so it's a non-issue.
> 
> I'm not sure what this statement means.  I guess it isn't encouraged, but I'm
> not sure if it's discouraged either.  I think it's just not discussed.  But my
> point was more that it's a non-const variable, and thus should not be named
> using the const naming convention, since that's misleading.

I agree it's probably as bad as "int kAnswer = 42;" but I still think it's the
preferable form.
 

> > Then, there's the copy-paste issue. It's just 4 bytes each but I'm far more
> > concerned by copy-pasting than the actual code.
> 
> Fair enough.
>
> > 
> > Static local variables are a whole other subject I won't touch here.
> 
> Just to make sure I'm not misinterpreted here, I wasn't suggesting function
> local static variables, but a function local static constant.  If you wanted
to
> reduce the copy-paste, then making it a file static constant is fine by me
too.

You think MSVC is that bright and makes a difference? Eh.

Powered by Google App Engine
This is Rietveld 408576698