ir/basic_block: std::move Terminal within SetTerminal and ReplaceTerminal

A terminal isn't a trivial type (and boost::variant is allowed to heap
allocate), so we can std::move it here to avoid a redundant copy.
This commit is contained in:
Lioncash 2019-05-23 22:05:44 -04:00 committed by MerryMage
parent 63eff4e7cc
commit b79ce71b0f

View file

@ -102,12 +102,12 @@ Terminal Block::GetTerminal() const {
void Block::SetTerminal(Terminal term) { void Block::SetTerminal(Terminal term) {
ASSERT_MSG(!HasTerminal(), "Terminal has already been set."); ASSERT_MSG(!HasTerminal(), "Terminal has already been set.");
terminal = term; terminal = std::move(term);
} }
void Block::ReplaceTerminal(Terminal term) { void Block::ReplaceTerminal(Terminal term) {
ASSERT_MSG(HasTerminal(), "Terminal has not been set."); ASSERT_MSG(HasTerminal(), "Terminal has not been set.");
terminal = term; terminal = std::move(term);
} }
bool Block::HasTerminal() const { bool Block::HasTerminal() const {