Skip to content

Improve unified_diff interface #1526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Rename differences map data member
  • Loading branch information
reuk committed Nov 1, 2017
commit f54db47233000079cf93edba9e033085e40ea24c
10 changes: 5 additions & 5 deletions src/goto-diff/unified_diff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ void unified_difft::get_diff(
dest.clear();

differences_mapt::const_iterator entry=
differences_map.find(function);
if(entry==differences_map.end())
differences_map_.find(function);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in some other pull request some days ago, I don't know where this need for renaming is coming from under current coding guidelines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been agreed with @peterschrammel that using an underscore suffix is acceptable when naming private data members. In this particular case, it allows us to name the getter differences_map() (which is nicer than get_differences_map). If we omitted the suffix, the identifiers would collide.

if(entry==differences_map_.end())
return;

goto_functionst::function_mapt::const_iterator old_fit=
Expand Down Expand Up @@ -304,7 +304,7 @@ void unified_difft::unified_diff(
const goto_programt &old_goto_program,
const goto_programt &new_goto_program)
{
differencest &differences=differences_map[identifier];
differencest &differences=differences_map_[identifier];
differences.clear();

if(old_goto_program.instructions.empty() ||
Expand Down Expand Up @@ -363,14 +363,14 @@ bool unified_difft::operator()()
for( ; ito!=old_funcs.end(); ++ito)
unified_diff(ito->first, ito->second->second.body, empty);

return !differences_map.empty();
return !differences_map_.empty();
}

void unified_difft::output(std::ostream &os) const
{
goto_programt empty;

for(const std::pair<irep_idt, differencest> &p : differences_map)
for(const std::pair<irep_idt, differencest> &p : differences_map_)
{
const irep_idt &function=p.first;

Expand Down
2 changes: 1 addition & 1 deletion src/goto-diff/unified_diff.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class unified_difft
typedef std::vector<differencet> differencest;
typedef std::map<irep_idt, differencest> differences_mapt;

differences_mapt differences_map;
differences_mapt differences_map_;

void unified_diff(
const irep_idt &identifier,
Expand Down