From ff45c3957858cdf189b73e11550da06fe4337b8e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 22 Sep 2020 17:31:53 -0400 Subject: General: Make use of std::nullopt where applicable Allows some implementations to avoid completely zeroing out the internal buffer of the optional, and instead only set the validity byte within the structure. This also makes it consistent how we return empty optionals. --- src/video_core/shader/ast.h | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src/video_core/shader/ast.h') diff --git a/src/video_core/shader/ast.h b/src/video_core/shader/ast.h index cca13bcde..8e5a22ab3 100644 --- a/src/video_core/shader/ast.h +++ b/src/video_core/shader/ast.h @@ -199,55 +199,48 @@ public: } std::optional GetGotoLabel() const { - auto inner = std::get_if(&data); - if (inner) { + if (const auto* inner = std::get_if(&data)) { return {inner->label}; } - return {}; + return std::nullopt; } Expr GetGotoCondition() const { - auto inner = std::get_if(&data); - if (inner) { + if (const auto* inner = std::get_if(&data)) { return inner->condition; } return nullptr; } void MarkLabelUnused() { - auto inner = std::get_if(&data); - if (inner) { + if (auto* inner = std::get_if(&data)) { inner->unused = true; } } bool IsLabelUnused() const { - auto inner = std::get_if(&data); - if (inner) { + if (const auto* inner = std::get_if(&data)) { return inner->unused; } return true; } std::optional GetLabelIndex() const { - auto inner = std::get_if(&data); - if (inner) { + if (const auto* inner = std::get_if(&data)) { return {inner->index}; } - return {}; + return std::nullopt; } Expr GetIfCondition() const { - auto inner = std::get_if(&data); - if (inner) { + if (const auto* inner = std::get_if(&data)) { return inner->condition; } return nullptr; } void SetGotoCondition(Expr new_condition) { - auto inner = std::get_if(&data); - if (inner) { + if (auto* inner = std::get_if(&data)) { inner->condition = std::move(new_condition); } } -- cgit v1.2.3