Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10570)

Issue 577380046: Issue 5694: Dot_configuration maintenance (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
4 years, 3 months ago by Dan Eble
Modified:
4 years, 3 months ago
Reviewers:
hanwenn
CC:
lilypond-devel_gnu.org
Visibility:
Public.

Description

https://sourceforge.net/p/testlilyissues/issues/5694/ 1: iterate properly in reverse The previous code would have malfunctioned for an empty container. 2: swap instead of copy 3: reduce repetition using a lambda function 4: use range-for loops 5: Dot_configuration "has a" instead of "is a" std::map It is considered poor form to create subclasses of standard containers because they lack virtual destructors. Inheriting privately from std::map avoids potential problems by preventing Dot_configuration from being treated as a std::map from the outside. (I didn't find any actual problems in this case.) Limiting the Dot_configuration interface to just the map methods that are actually used makes it easier to understand how Dot_configuration is used without searching the entire code.

Patch Set 1 : iterate properly in reverse #

Patch Set 2 : swap instead of copy #

Patch Set 3 : reduce repetition using a lambda function #

Patch Set 4 : use range-for loops #

Patch Set 5 : Dot_configuration "has a" instead of "is a" std::map #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+44 lines, -69 lines) Patch
M lily/dot-column.cc View 1 2 3 1 chunk +2 lines, -8 lines 0 comments Download
M lily/dot-configuration.cc View 1 2 3 5 chunks +35 lines, -60 lines 1 comment Download
M lily/include/dot-configuration.hh View 1 2 3 4 1 chunk +7 lines, -1 line 0 comments Download

Messages

Total messages: 8
Dan Eble
swap instead of copy
4 years, 3 months ago (2020-01-25 16:13:02 UTC) #1
Dan Eble
reduce repetition using a lambda function
4 years, 3 months ago (2020-01-25 16:14:01 UTC) #2
Dan Eble
use range-for loops
4 years, 3 months ago (2020-01-25 16:14:24 UTC) #3
Dan Eble
Dot_configuration "has a" instead of "is a" std::map
4 years, 3 months ago (2020-01-25 16:14:53 UTC) #4
Dan Eble
4 years, 3 months ago (2020-01-25 16:23:14 UTC) #5
hanwenn
https://codereview.appspot.com/577380046/diff/553430046/lily/dot-configuration.cc File lily/dot-configuration.cc (right): https://codereview.appspot.com/577380046/diff/553430046/lily/dot-configuration.cc#newcode69 lily/dot-configuration.cc:69: auto process_entry = [d, k, &new_cfg, &offset](const value_type &ent) ...
4 years, 3 months ago (2020-01-25 18:24:32 UTC) #6
Dan Eble
On 2020/01/25 18:24:32, hanwenn wrote: > https://codereview.appspot.com/577380046/diff/553430046/lily/dot-configuration.cc > File lily/dot-configuration.cc (right): > > https://codereview.appspot.com/577380046/diff/553430046/lily/dot-configuration.cc#newcode69 > ...
4 years, 3 months ago (2020-01-25 18:37:23 UTC) #7
hanwenn
4 years, 3 months ago (2020-01-25 18:45:28 UTC) #8
On Sat, Jan 25, 2020 at 7:37 PM <nine.fierce.ballads@gmail.com> wrote:
>
> On 2020/01/25 18:24:32, hanwenn wrote:
> >
>
https://codereview.appspot.com/577380046/diff/553430046/lily/dot-configuratio...
> > File lily/dot-configuration.cc (right):
> >
> >
>
https://codereview.appspot.com/577380046/diff/553430046/lily/dot-configuratio...
> > lily/dot-configuration.cc:69: auto process_entry = [d, k, &new_cfg,
> > &offset](const value_type &ent)
> > what does this syntax do?
>
> https://en.cppreference.com/w/cpp/language/lambda
>
> It defines a function named "process_entry" taking one argument (const
> value_type &).  The body of the function can access variables d and k by
> value, and variables new_cfg and offset by reference.  I think "this"
> might also be captured implicitly in this context, but I'd have to go to
> the documentation to refresh my memory.
>
> An alternative to using a lambda would be to move this stuff to a
> private member function, or maybe a static function in this file.

Thanks for the explanation!

-- 
Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b