From b79ce71b0fce48c1ce1f0242d14d4806ca29e64e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 23 May 2019 22:05:44 -0400 Subject: [PATCH] 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. --- src/frontend/ir/basic_block.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/ir/basic_block.cpp b/src/frontend/ir/basic_block.cpp index 02c6ce00..3e91d17d 100644 --- a/src/frontend/ir/basic_block.cpp +++ b/src/frontend/ir/basic_block.cpp @@ -102,12 +102,12 @@ Terminal Block::GetTerminal() const { void Block::SetTerminal(Terminal term) { ASSERT_MSG(!HasTerminal(), "Terminal has already been set."); - terminal = term; + terminal = std::move(term); } void Block::ReplaceTerminal(Terminal term) { ASSERT_MSG(HasTerminal(), "Terminal has not been set."); - terminal = term; + terminal = std::move(term); } bool Block::HasTerminal() const {