Skip to content

Commit

Permalink
added goto_programt::add(instruction)
Browse files Browse the repository at this point in the history
The method takes an rvalue reference; this eliminates the need to construct
the members of instructiont and then copy them.
  • Loading branch information
Daniel Kroening committed Jan 26, 2019
1 parent 5035050 commit fddaec5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/goto-programs/goto_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -645,20 +645,26 @@ class goto_programt
instructions.splice(target, p.instructions);
}

/// Adds a given instruction at the end.
/// \return The newly added instruction.
targett add(instructiont &&instruction)
{
instructions.push_back(std::move(instruction));
return --instructions.end();
}

/// Adds an instruction at the end.
/// \return The newly added instruction.
targett add_instruction()
{
instructions.push_back(instructiont());
return --instructions.end();
return add(instructiont());
}

/// Adds an instruction of given type at the end.
/// \return The newly added instruction.
targett add_instruction(goto_program_instruction_typet type)
{
instructions.push_back(instructiont(type));
return --instructions.end();
return add(instructiont(type));
}

/// Output goto program to given stream
Expand Down

0 comments on commit fddaec5

Please sign in to comment.