From 29bff642fc0b1624350a78c673366934335a261b Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Thu, 4 May 2023 11:53:31 +0000 Subject: [PATCH] ir: Use std::optional::value_or to simplify code Change-Id: Iaf3ec58a70cd49c508c3279f62c029440b82c599 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131520 Reviewed-by: Dan Sinclair Kokoro: Kokoro Commit-Queue: Dan Sinclair --- src/tint/ir/builder_impl.cc | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/tint/ir/builder_impl.cc b/src/tint/ir/builder_impl.cc index 56849d2cea..2a42917420 100644 --- a/src/tint/ir/builder_impl.cc +++ b/src/tint/ir/builder_impl.cc @@ -226,19 +226,11 @@ void BuilderImpl::EmitFunction(const ast::Function* ast_func) { ir_func->pipeline_stage = Function::PipelineStage::kCompute; auto wg_size = sem->WorkgroupSize(); - - uint32_t x = wg_size[0].value(); - uint32_t y = 1; - uint32_t z = 1; - if (wg_size[1].has_value()) { - y = wg_size[1].value(); - - if (wg_size[2].has_value()) { - z = wg_size[2].value(); - } - } - - ir_func->workgroup_size = {x, y, z}; + ir_func->workgroup_size = { + wg_size[0].value(), + wg_size[1].value_or(1), + wg_size[2].value_or(1), + }; break; } default: {