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

Issue 1505403003: Remove const declaration of POD locals in actions bar code (Closed)

Created:
5 years ago by tdanderson
Modified:
5 years ago
Reviewers:
Devlin, Peter Kasting
CC:
chromium-reviews, tfarina
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Remove const declaration of POD locals in actions bar code As a follow up to the discussion in https://codereview.chromium.org/1469423002/, remove the const declaration of POD local variables in the actions bar code. BUG=555031, 550816 TEST=none

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+9 lines, -9 lines) Patch
M chrome/browser/ui/toolbar/toolbar_actions_bar.cc View 1 chunk +4 lines, -4 lines 0 comments Download
M chrome/browser/ui/views/toolbar/browser_actions_container.cc View 1 chunk +5 lines, -5 lines 0 comments Download

Messages

Total messages: 13 (3 generated)
tdanderson
Hi Devlin, please take a look.
5 years ago (2015-12-09 19:57:10 UTC) #2
Devlin
lgtm. Thanks :)
5 years ago (2015-12-09 20:01:45 UTC) #3
tdanderson
On 2015/12/09 20:01:45, Devlin wrote: > lgtm. > > Thanks :) np :)
5 years ago (2015-12-09 20:08:05 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1505403003/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1505403003/1
5 years ago (2015-12-09 20:11:14 UTC) #6
Peter Kasting
Not LGTM. I own the c/b/ui code and encourage local consts as much as possible. ...
5 years ago (2015-12-09 21:06:53 UTC) #8
Devlin
On 2015/12/09 21:06:53, Peter Kasting wrote: > Not LGTM. > > I own the c/b/ui ...
5 years ago (2015-12-09 21:23:46 UTC) #9
Peter Kasting
On 2015/12/09 21:23:46, Devlin wrote: > On 2015/12/09 21:06:53, Peter Kasting wrote: > > Not ...
5 years ago (2015-12-09 21:33:29 UTC) #10
Devlin
On 2015/12/09 21:33:29, Peter Kasting wrote: > I read your comments, but I was not ...
5 years ago (2015-12-09 21:56:28 UTC) #11
Peter Kasting
On 2015/12/09 21:56:28, Devlin wrote: > On 2015/12/09 21:33:29, Peter Kasting wrote: > > I ...
5 years ago (2015-12-09 22:01:35 UTC) #12
tdanderson
5 years ago (2015-12-17 21:10:37 UTC) #13
On 2015/12/09 22:01:35, Peter Kasting wrote:
> On 2015/12/09 21:56:28, Devlin wrote:
> > On 2015/12/09 21:33:29, Peter Kasting wrote:
> > > I read your comments, but I was not convinced that local consts on POD
types
> > > don't make sense.  The readability benefit of knowing the value doesn't
> change
> > > is irrespective of whether the local is of POD type.
> > 
> > The difference for POD vs. non-POD is that with a POD type, it should almost
> > always be immediately clear if the value changes by looking at the code in
the
> > function, because the operations that can change a POD value are pretty
> limited
> > and, hopefully, self-evident.
> 
> That requires you to scan all the code in a function to know what happens. 
> "const" tells you immediately, right where you're looking.
> 
> The major work here is in scanning the function.  The issue of having to know
> what class methods do is comparatively minor; generally you know what the
> methods do or can make reasonable guesses.
> 
> > It seems like putting const on function-local POD types is just added noise.

> If
> > I care whether or not it's const, it should be clear from the surrounding
> code.
> 
> Again, the goal is to never look at any surrounding code, which is why this is
> _less_ work for a reader, not more.  There's simply no way to argue that even
> the most rapid scan of a function is "less work" than reading a single word at
a
> declaration site.
>  
> > Adding const makes it (very slightly) more work on me as the reader and
(again
> > very slightly) more work on whoever later needs to modify the variable
> 
> Local const has caught bugs in my own changes where I accidentally modified
> values I shouldn't have.  It's also frequently helped prod me into writing
> better changes -- often a variable being const makes me think about whether
> making it non-const is really the best way of doing something, and I end up
> finding a clearer method.
> 
> So, for the benefit of both reading and writing, my experience matches the
style
> guide recommendations: use const wherever possible.

Closing this out.

Powered by Google App Engine
This is Rietveld 408576698